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
26
votes
9 answers

How do I copy SQL Server 2012 database to localdb instance?

I'm looking to copy a SQL Server 2012 Standard database to my localdb instance. I've tried the wizard which complains that localdb isn't a SQL Server 2005 or later express instance. I also did a backup/restore but upon the restore in my localdb I…
Corey Blair
  • 469
  • 1
  • 7
  • 13
26
votes
1 answer

Express with Advanced Services, can't create Full Text Index

I have installed SQL Server 2012 Express Edition Advanced Services which states that it includes Full-text indexing. Here is a link that states this: http://msdn.microsoft.com/en-us/library/cc645993.aspx I have confirmed that Full-text service is…
TreK
  • 1,144
  • 2
  • 13
  • 25
25
votes
7 answers

How to join to tables whose names are stored as values in another table?

Ι have some tables ( eg. [Table1], [Table2], [Table3] and so on ) with a [ID] as primary key and a RecTime as DATETIME on each. Αlso Ι have a table [Files] that hold files in a varbinary(max) column, and refers to the other tables having their Names…
armen
  • 1,253
  • 3
  • 23
  • 41
25
votes
6 answers

SQL Server Change Primary Key Data Type

I am working on SQL Server 2012: I have a table with a primary key column as INT. I need to change this to a GUID. Do I alter the table and remove int column as primary key? Add the GUID column and set it as Primary and drop the old INT…
Guygar
  • 449
  • 1
  • 5
  • 8
25
votes
8 answers

Cannot continue the execution because the session is in the kill state. while building clustered index

I get the following error while trying to create a clustered index The statement has been terminated. Msg 596, Level 21, State 1, Line 0 Cannot continue the execution because the session is in the kill state. Msg 0, Level 20, State 0, Line…
user2904235
  • 381
  • 1
  • 5
  • 9
25
votes
2 answers

DT_Decimal Data Type Cutting off Decimal

I have a flat file source that grabs a decimal value for the column Note Amount. The Source system specifies that this is a DECIMAL(12,2) file. I have the column in SSIS set to be DT_Decimal The particular Flat file has a value of 122735.13 for one…
Zane
  • 4,129
  • 1
  • 21
  • 35
25
votes
1 answer

What is the difference between ExecuteSqlCommand vs SqlQuery ? when doing a db access?

I have had a couple of suggestions on how to access data from my database: var allMyIds = context.Database.ExecuteSqlCommand("select id from AspNetUserLogins"); var allMyIds = context.Database.SqlQuery("select id from…
25
votes
2 answers

Code first custom SQL migration timeout exception

I am trying to create FULL TEXT index using Entity Framework Migration by executing custom Sql. My migration class looks like this: public partial class DocumentContentFullTextIndex : DbMigration { public override void Up() { …
25
votes
3 answers

Use Collate in CONCAT

I was trying to concatonate 2 columns with a whitespace in between and got a collation error: SELECT DISTINCT p.PERSON_ID, p.ID_NUMBER, CONCAT(p.FULLNAMES, CONCAT(' ', p.SURNAME)) AS NAME, o.ORG_NAME, w.WARD_DESCRIPTION AS WARD, …
Carel
  • 2,063
  • 8
  • 39
  • 65
25
votes
2 answers

SQL Server dbo.sysdiagrams is a user table or system table

When use Database Diagrams in a simple database, SQL Server create a dbo.sysdiagrams table in the Table\Systam Tables node (in Microsoft management studio\object explorer). But sysdiagrams table marked as user table in SQL Server. you can get user…
mehdi lotfi
  • 11,194
  • 18
  • 82
  • 128
25
votes
1 answer

SQL-Server: What does NOUNLOAD and STATS mean in sql command line when restoring a DB?

When i go to restore my database in SQL server 2012 i can let display the script or command line action as you know. What do these additional parameters do, Nounload and stats = 10. RESTORE DATABASE [db2] FROM DISK = N'C:\folder\db2.bak' WITH FILE…
RayofCommand
  • 4,054
  • 17
  • 56
  • 92
25
votes
18 answers

Cannot install adventureworks 2012 database - Operating system error 5: Access is denied

I am trying to install AdventureWorks 2012 database in sql server 2012. I got the mdf file from this link - http://msftdbprodsamples.codeplex.com/releases/view/93587 Here is the name of the file I downloaded - AdventureWorks2012_Database.zip I am…
Steam
  • 9,368
  • 27
  • 83
  • 122
24
votes
2 answers

Adding a query hint when calling Table-Valued Function

I'm calling a Table-Valued Function from entity framework and need to be able to add the option (recompile) to it because the execution plan it picks up is not optimal. Running the query in SQL Server Management Studio, it would look something like…
Matt Burland
  • 44,552
  • 18
  • 99
  • 171
24
votes
1 answer

How to format datetime in SQL SERVER

I am trying to port MySQL function DATE_FORMAT(date,'%y-%m-%d %h:%i:%s %p') to MsSQL equivalent by using CONVERT(). How to format equivalent datetime string in SQL SERVER 2012 to give this output '2014-05-24 01:24:37 AM'?
Ankit
  • 2,448
  • 3
  • 20
  • 33
24
votes
8 answers

Backup a database on a HDD with a different sector size

In our development environment we have long been using a particular backup and restore script for each of our products through various SQL Server versions and different environment configurations with no issues. Recently we have upgraded to SQL…
codemonkeh
  • 2,054
  • 1
  • 20
  • 36