sql-server-2016

Error Code 0x84BB0001 when installing SQL Server 2016

余生颓废 提交于 2020-08-23 09:28:33
问题 OS: Windows Server 2012 R2 When attempting to install SQL Server 2016 on a Server that is already running SQL 2012 I receive 0x84BB0001. This stops my Database Engine Service from installing correctly. There is no antivirus running. Ive deleted the contents of C:/Users/[UserName]/AppData/Local/Microsoft_Corporatio Ive given admin rights to the following: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\130 Really at a loss

Escaping characters in T-SQL OPENJSON queries

牧云@^-^@ 提交于 2020-08-23 03:44:42
问题 I have the following JSON Data DECLARE @jsonData NVARCHAR(MAX) SET @jsonData = '{ "insertions":[ { "id":"58735A79-DEA8-462B-B3EB-C2797CA9D44E", "last-modified":"2017-08-08 13:07:32", "label":"HelloWorld1" }, { "id":"00565BCD-4240-46CF-A48F-849CB5A8114F", "last-modified":"2017-08-08 13:11:38", "label":"HelloWorld12" } ] }' And trying to perform a select from it: SELECT * FROM OPENJSON(JSON_QUERY(@jsonData,'$.insertions')) WITH (uuid UNIQUEIDENTIFIER '$.id', modified DATETIME '$.last-modified',

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

百般思念 提交于 2020-08-22 02:23:11
问题 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 project with an employee temporal table: I used the edmx to map the table to entity (thanks to Matt Ruwe): Everything works fine with pure sql statements: using (var context = new TemporalEntities()) { var employee = context.Employees.Single(e => e

How to read field name with space in Json using OPENJSON in SQL Server 2016

不羁的心 提交于 2020-08-20 03:59:35
问题 How can I read value from json file in that field name contains space using OPENJSON in Sql Server 2016 . See the below code: DECLARE @json NVARCHAR(MAX) SET @json = N'{ "full name" : "Jayesh Tank"}'; SELECT * FROM OPENJSON(@json) WITH ( [name] [varchar](60) '$.full name') Also another sample code in that space is after field name. SET @json = N'{ "name " : "abc"}'; SELECT * FROM OPENJSON(@json) WITH ( [name] [varchar](60) '$.name') '$.name' will return null.Is there way to read this value?

String_agg in sql server 2016

风格不统一 提交于 2020-08-06 08:03:27
问题 Here is my code in sql server 2016 insert into @entdef_queries(entitydefid,squery) select A.entitydefid , ( select String_agg(cols,ioperator) from ( Select case when lower(b.metricdatatype) like 'string%' or lower(b.metricdatatype) like '%char%' or lower(b.metricdatatype) ='bit' or lower(b.metricdatatype) like 'date%' then ' lower("'+ b.metricname +'") ' + b.metriccondition +' '''+ b.value1 +''' ' when lower(b.metricdatatype) not like 'string%' and lower(b.metricdatatype) like '%char%' and

Insert nested json array into multiple tables in sql server

|▌冷眼眸甩不掉的悲伤 提交于 2020-06-25 06:47:17
问题 I have following Json Object in Sql server. I want to insert this data into multiple tables with their relation (i.e. foreign key): DECLARE @JsonObject NVARCHAR(MAX) = N'{ "FirstElement":{ "Name":"ABC", "Location":"East US", "Region":"West US", "InnerElement":[ { "Name":"IE1", "Description":"IE1 Description", "Type":"Small", "InnerMostElement":[ { "Key":"Name", "Value":"IME1" }, { "Key":"AnotherProperty", "Value":"Value1" } ] }, { "Name":"IE2", "Description":"IE2 Description", "Type":"Medium"

Insert nested json array into multiple tables in sql server

我与影子孤独终老i 提交于 2020-06-25 06:47:08
问题 I have following Json Object in Sql server. I want to insert this data into multiple tables with their relation (i.e. foreign key): DECLARE @JsonObject NVARCHAR(MAX) = N'{ "FirstElement":{ "Name":"ABC", "Location":"East US", "Region":"West US", "InnerElement":[ { "Name":"IE1", "Description":"IE1 Description", "Type":"Small", "InnerMostElement":[ { "Key":"Name", "Value":"IME1" }, { "Key":"AnotherProperty", "Value":"Value1" } ] }, { "Name":"IE2", "Description":"IE2 Description", "Type":"Medium"

Multiple SELECT statements into a single JSON

…衆ロ難τιáo~ 提交于 2020-06-23 04:46:31
问题 I'm convinced this must be answered somewhere but for the life of me I just can't seem to find anything no matter how much I change my search phrases. I need to select data from two completely independent tables and export the information to JSON. In this case, they're both 1 record in each table. If I select just 1 at a time and export to JSON, they're 1 record, but when I join the two single records in SQL and then export to JSON, they're 1 record arrays. Just 1 record SQL Input: DECLARE