Questions tagged [sql-server-2016]

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

Microsoft SQL Server 2016 v.13.0.1601.5 Ready To Manufacture (RTM), was released on June 1, 2016.

There are many editions of SQL Server 2016:

1- Entreprise Edition : Comprehensive, mission-critical in-memory performance with unparalleled security, mission critical high availability, an end-to-end enterprise business intelligence solution with mobile BI built in, in-database advanced analytics at scale, and unlimited virtualization with software assurance. Enterprise edition provides the highest scale and performance for Tier-1 workloads.

2- Standard: Find rich programming capabilities, security innovations, and fast performance for applications and data marts. Easily upgra

3- Developer: Build, test, and demonstrate applications in a non-production environment with this free, full-featured set of SQL Server 2016 SP1 Enterprise edition software.

4- Express: Deploy small databases in production environments with this free, entry-level database that’s ideal for building small, data-driven applications up to 10 GB of disk size.

5- Compact: Free, embedded database app for building ASP.NET websites and Windows desktop applications.

6- Web: Secured, cost effective, and highly scalable data platform for public web sites—available to third-party hosting service providers only.

References

3372 questions
1960
votes
31 answers

How to check if a column exists in a SQL Server table?

I need to add a specific column if it does not exist. I have something like the following, but it always returns false: IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'myTableName' AND…
Maciej
  • 19,978
  • 3
  • 18
  • 23
283
votes
2 answers

How do I move a table into a schema in T-SQL

I want to move a table into a specific Schema using T-SQL? I am using SQL Server 2008.
Lukasz
  • 8,382
  • 11
  • 42
  • 69
199
votes
13 answers

SQL Server: Filter output of sp_who2

Under SQL Server, is there an easy way to filter the output of sp_who2? Say I wanted to just show rows for a certain database, for example.
Craig Schwarze
  • 10,779
  • 14
  • 58
  • 79
83
votes
2 answers

Why is 199.96 - 0 = 200 in SQL?

I have some clients getting weird bills. I was able to isolate the core problem: SELECT 199.96 - (0.0 * FLOOR(CAST(1.0 AS DECIMAL(19, 4)) * CAST(199.96 AS DECIMAL(19, 4)))) -- 200 what the? SELECT 199.96 - (0.0 * FLOOR(1.0 * CAST(199.96 AS…
Silverdust
  • 1,443
  • 13
  • 20
82
votes
7 answers

Is there a LastIndexOf in SQL Server?

I am trying to parse out a value from a string that involves getting the last index of a string. Currently, I am doing a horrible hack that involves reversing a string: SELECT REVERSE(SUBSTRING(REVERSE(DB_NAME()), 1, CHARINDEX('_',…
AngryHacker
  • 54,471
  • 90
  • 289
  • 523
48
votes
3 answers

SQL Server OPENJSON read nested json

I have some json that I would like to parse in SQL Server 2016. There is a hierarchy structure of Projects->Structures->Properties. I would like to write a query that parses the whole hierarchy but I don't want to specify any elements by index…
Slade
  • 1,919
  • 2
  • 16
  • 23
44
votes
1 answer

OPENJSON does not work in SQL Server?

I want to use JSON functions in SQL Server 2016, but when I try to execute OPENJSON function, I get the following error: Msg 208, Level 16, State 1, Line 1 Invalid object name 'openjson'. Why it does not work? I have SQL Server 2016 RC version.
Iva
  • 443
  • 1
  • 4
  • 4
40
votes
6 answers

SQL to JSON - array of objects to array of values in SQL 2016

SQL 2016 has a new feature which converts data on SQL server to JSON. I am having difficulty in combining array of objects into array of values i.e., EXAMPLE - CREATE TABLE #temp (item_id VARCHAR(256)) INSERT INTO #temp VALUES…
30
votes
3 answers

How do you OPENJSON on Arrays of Arrays

I have a JSON structure where there are Sections, consisting of multiple Renders, which consist of multiple Fields. How do I do 1 OPENJSON call on the lowest level (Fields) to get all information from there? Here is an example JSON: Declare @layout…
Bill Software Engineer
  • 6,246
  • 19
  • 72
  • 141
27
votes
3 answers

Create nested JSON arrays using FOR JSON PATH

I need to create a JSON output from a query that uses inner join between two tables with a one to many relationship. I would like the values of the secondary table to be nested as array properties of the primary table. Consider the following…
ATC
  • 717
  • 1
  • 8
  • 14
26
votes
3 answers

NHibernate HQL Generator to support SQL Server 2016 temporal tables

I am trying to implement basic support for SQL Server 2016 temporal tables in NHibernate 4.x. The idea is to alter SQL statement from SELECT * FROM Table t0 to SELECT * FROM Table FOR SYSTEM_TIME AS OF '2018-01-16 00:00:00' t0 You can find…
veeroo
  • 722
  • 6
  • 22
24
votes
3 answers

How can I use System-Versioned Temporal Table with Entity Framework?

I can use temporal tables in SQL Server 2016. Entity Framework 6 unfortunately does not know this feature yet. Is there the possibility of a workaround to use the new querying options (see msdn) with Entity Framework 6? I created a simple demo…
cSteusloff
  • 2,110
  • 4
  • 22
  • 45
24
votes
5 answers

LocalDB parent instance version invalid: MSSQL13E.LOCALDB

I'm unable to add a database on a developer machine. I'm running win 10, visual studio 2015. I re-installed SQL server 2016 twice, last time with firewall disabled it all gave green marks in the end. While i can create databases in VS2015 SQL server…
Peter
  • 1,706
  • 15
  • 35
24
votes
4 answers

SQL Replace multiple different characters in string

I need to replace multiple characters in a string. The result can't contain any '&' or any commas. I currently have: REPLACE(T2.[ShipToCode],'&','and') But how do you put multiple values in? Many thanks!
coblenski
  • 789
  • 2
  • 6
  • 18
23
votes
5 answers

How to get column-level dependencies in a view

I've made some research on the matter but don't have solution yet. What I want to get is column-level dependencies in a view. So, let's say we have a table like this create table TEST( first_name varchar(10), last_name varchar(10), …
Roman Pekar
  • 92,153
  • 25
  • 168
  • 181
1
2 3
99 100