Questions tagged [sql-server-2012]

Use this tag for questions specific to the 2012 version of Microsoft's SQL Server.

SQL Server 2012 (codename Denali, version 11.00), released in March 2012, is the successor to SQL Server 2008 R2.

This tag covers questions specific to the 2012 version of the database engine. It is recommended that the tag is also used when tagging questions with this version specific tag.

Programmability topics may include but are not limited to

  • FileTable
  • Semantic search
  • Metadata discovery
  • Ad-hoc Query Pagination
  • Sequence objects
  • Throw statement
  • Conversion functions
    • PARSE
    • TRY_CONVERT
    • TRY_PARSE
  • Date and time functions
    • DATEFROMPARTS
    • DATETIME2FROMPARTS
    • DATETIMEFROMPARTS
    • DATETIMEOFFSETFROMPARTS
    • EOMONTH
    • SMALLDATETIMEFROMPARTS
    • TIMEFROMPARTS
  • Logical functions
    • CHOOSE
    • IIF
  • String functions
    • CONCAT
    • FORMAT
  • Analytic functions
    • CUME_DIST
    • LAST_VALUE
    • PERCENTILE_DISC
    • FIRST_VALUE
    • LEAD
    • PERCENT_RANK
    • LAG
    • PERCENTILE_CONT
17074 questions
3
votes
1 answer

Cardinality Estimate warning when a function(IS_MEMBER ) is used in where clause in SQLServer

Consider the following Scenarios Test data CREATE TABLE T1 ( COL1 numeric (6, 0) NOT NULL, COL2 numeric (18, 0) NOT NULL, COL3 numeric (18, 0) NOT NULL, COL4 numeric (5, 0) NOT NULL, COL5 numeric (18, 0) NOT…
3
votes
1 answer

Getting correct data type of columns from view

I am trying to create a table from view. This view is from a join between multiple tables. But in the target table almost all columns have either Varchar(8000) or NVARCHAR(4000) which is not true for any of the columns. I tried to get the structure…
Zerotoinfinity
  • 6,290
  • 32
  • 130
  • 206
3
votes
1 answer

Why are these SQL Server statistics outdated, when it's set to auto-update?

We have a SQL Server 2012 instance, with auto-statitics set to ON for the DB: But then i ran a query to check some statistics, and some haven't been updated in a while: Why is this the case? Is there a rule to whether SQL Server updates…
RPM1984
  • 72,246
  • 58
  • 225
  • 350
3
votes
4 answers

how to split single integer value columns into n column?

I have a SQL Server table table_name like: col1 1 2 3 4 5 6 7 8 9 . . . N i want output like below col-1 | col-2 | col-3 | col-4 |col-5 ------------------------------- 1 | 2 | 3 | 4 |5 6 | 7 | 8 | 9 |10 11 |…
sankar d
  • 31
  • 2
3
votes
1 answer

Copy the encrypted column to another database SQL Server 2012

I have created a database and it has a table with an encrypted column. If you insert encrypted information into this column, then it can be decrypted very easily. But, if you create the exact same table in another database, with the same key and…
Evgeny
  • 597
  • 2
  • 7
  • 16
3
votes
2 answers

aggregation of comma-separated values in-position

I have one table where there is two column loan no and counter_value. Against each loan no there is the list of comma separated values are stored. declare @tbl table (loanno varchar(100) , counter_value varchar(200) ) insert into…
hieko
  • 383
  • 1
  • 5
  • 13
3
votes
2 answers

Subtraction by sell order in TSQL

I have 2 tables as following: Table 1: ID_M, Date, Reservation 001, 2014, 5 001, 2015, 10 001, 2016, 18 002, 2015, 6 002, 2016, 22 Table 2: ID_M, ID_type, Priority,Product_Total 001, 1111, 2, 10 001, 2222, …
Shania
  • 45
  • 7
3
votes
1 answer

SQL Server - While Loop vs "LOCAL STATIC READ_ONLY FORWARD_ONLY" Cursor

I have created many cursors in my application to do row by row operations in each cursor single run I selected only 500 or 1000 records so that the cursor can be completed as quickly as postilion in single run, in other words I have selected limited…
Techleadz Team
  • 198
  • 2
  • 15
3
votes
2 answers

bcp command outputting Chinese characters instead of table

I have a batch file that imports a delimited text file into SQL Server using BCP, runs some processing using SQLCMD, and then outputs the processed data via BCP. It currently gives a string of Chinese characters instead of a delimited text table.…
Rominus
  • 1,181
  • 2
  • 14
  • 29
3
votes
2 answers

How use Bulk insert csv to sql server with datetime format correct?

i want use bulk insert file csv insert to SQL Server 2012. same column have datetime but use bulk insert datetime format not work and i not use SSIS. Example Create Table CREATE TABLE [dbo].[scanindex_test]( [request_no] [varchar](13) NOT…
nettoon493
  • 17,733
  • 7
  • 30
  • 45
3
votes
1 answer

SQL Server : clustered index slow

I have 2 database tables: Message table that contains gps message MessageData that contains message sensors values I join them to get sensor values between 2 dates. The query returns results slowly with 99% of time seeking the clustered…
Ayman Elarian
  • 301
  • 2
  • 15
3
votes
3 answers

Laravel, SQL varchar

I am Using laravel with MS SQL. When string datatype is defined in the migration (code attahced) laravel create a nvarchar datatype in the Database instead of varchar. How to restrict laravel or SQL Server to create varchar datatype when a datatype…
3
votes
1 answer

How to EXEC a stored procedure from SSIS to get its output to text file

I wrote a stored procedure that reads records into a temp table and then creates a pivoted output from the data in the temp table. Running the stored procedure from SSMS works just fine. What I am facing problems is now that I am trying to create…
erasmo carlos
  • 664
  • 5
  • 16
  • 37
3
votes
2 answers

table index for DISTINCT values

In my stored procedure, I need "Unique" values of one of the columns. I am not sure if I should and if I should, what type of Index I should apply on the table for better performance. No being very specific, the same case happens when I retrieve…
Harsh Shankar
  • 506
  • 5
  • 16
3
votes
4 answers

How to delete data based on time interval

I have a table in my database.The table has a field VehId(Int) and trackdt(Datetime) My table has 3000 billion rows(yes, that's right 3000 billion). so i want to delete old data. but i want to delete data based on time interval. I want to delete…