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
24
votes
3 answers

Can't Export Data-tier Application for Azure

I am trying to create a .bacpac file of my SQL 2012 database. In SSMS 2012 I right click my database, go to Tasks, and select Export Data-tier Application. Then I click Next, and it gives me this error: Error SQL71564: Element Login: [myusername]…
user1477388
  • 20,790
  • 32
  • 144
  • 264
24
votes
3 answers

Dynamically assign filename to excel connection string

This is my very first time playing with SSIS in SQL Server 2012. I can successfully read an excel file and load its content to a table in SQL server 2012. The task is a simple direct read excel file then copy to sql server with no validation or…
user1205746
  • 3,110
  • 11
  • 44
  • 73
24
votes
2 answers

Unexpected results when using FIRST_VALUE() in SQL Server 2012

When I use FIRST_VALUE on a data set that I construct by hand I get one result, and when I use it on a data set that results from a left join, I get a different result - even though the data sets appear to me to contain the exact same data values.…
24
votes
2 answers

Table-Valued function - Order by is ignored in output

We are moving from SQL Server 2008 to SQL Server 2012 and immediately noticed that all our table-valued functions no longer deliver their temp table contents in the correctly sorted order. CODE: INSERT INTO @Customer SELECT Customer_ID,…
Tanis Draven
  • 425
  • 1
  • 4
  • 14
24
votes
3 answers

How can I restore a database backup file (.bak) from SQL Server 2012 into SQL Server 2008 Express?

A database that was originally from SQL Server 2008, was restored into SQL Server 2012. A backup from SQL Server 2012 was made and I am trying to restore it on my local SQL Server 2008 Express. However I get an error 'Specified cast is not valid'…
stormwild
  • 2,855
  • 2
  • 31
  • 38
23
votes
5 answers

how to insert data parellel in three different tables

I have a stored procedure which will insert the bulk of records, now is there any possibility to insert data into 3 tables in parallel; First table inserting 1 million records. Second table inserting 1.5 million records. Third table inserting 500k…
katraj
  • 381
  • 1
  • 8
23
votes
2 answers

How to calculate 90th Percentile, SD, Mean for data in SQL

Hi I have a table facility. Which holds a score for each day (Multiple scores can be reported each day and both would be valid) I need to calculate the 90th percentile, SD, and Mean for score by month. Facility: Id Month Date score 1 Jan 1…
Agga
  • 285
  • 1
  • 2
  • 13
23
votes
2 answers

Add multiple constraints in one statement

I am supposed to modify my current table named MEMBER in Microsoft SQL Server 2012. I am trying to modify the tables ALTER TABLE MEMBER ADD CONSTRAINT U_MEMBERID UNIQUE(MEMBER_ID), primary key (MEMBER_ID); ADD CONSTRAINT Sys_date DEFAULT GETDATE()…
user3579754
  • 837
  • 2
  • 7
  • 10
23
votes
5 answers

How can I determine if a Sequence exist in SQL Server 2012?

I need to create a SQL script to determine if a sequence exists in a SQL Server 2012 database. I am familiar with process for determine if a stored procedure exist but not sequence. Thank you.
Prabhakar K
  • 258
  • 1
  • 2
  • 6
23
votes
3 answers

Sequence as default value for a column

I have already created a sequence: create sequence mainseq as bigint start with 1 increment by 1 How do I use this sequence as the default value of a column? create table mytable( id bigint not null default mainseq -- how? code …
Endy Tjahjono
  • 24,120
  • 23
  • 83
  • 123
23
votes
1 answer

How do you store static data in your SQL Server Database Project in VS 2012

I am trying to use the SQL Server Database Project to keep all our table, stored procedure, views etc scripts. I now want a way to be able to keep all our reference (static) data as well. When the tool or project is run it will install all the DB…
uriDium
  • 13,110
  • 20
  • 78
  • 138
23
votes
3 answers

Why does SQL Server say "Starting Up Database" in the event log, twice per second?

I have a SQL Server [2012 Express with Advanced Services] database, with not much in it. I'm developing an application using EF Code First, and since my model is still in a state of flux, the database is getting dropped and re-created several times…
Gary McGill
  • 26,400
  • 25
  • 118
  • 202
22
votes
3 answers

How do you test for the existence of a user in SQL Server?

I'd like to drop a user in a SQL Server script but I'll need to test for existence first or I'll get script errors. When dropping tables or stored procs, I check the sysobjects table like so: IF EXISTS ( SELECT * FROM sysobjects …
Mark Brittingham
  • 28,545
  • 12
  • 80
  • 110
22
votes
3 answers

Convert Datetime to Unix timestamp

In Microsoft SQL Server 2012 or above, is it possible to convert a datetime value to Unix time stamp in a single select statement? If so, how can it be done?
O A
  • 359
  • 1
  • 2
  • 7
22
votes
7 answers

SQL Server 2012 Random string from a list

say I have 3 values, Bill, Steve, Jack. and I want to randomly update a table with those values, eg Update contacts set firstname = ('Bill','Steve','Jack') where city = 'NY' how do I randomize these values? Thanks
Bill
  • 751
  • 2
  • 8
  • 18