sql-server-2016

OPENJSON does not work in SQL Server?

為{幸葍}努か 提交于 2019-11-30 04:27:48
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. Could you check compatibility level on database? OPENJSON is available under compatibility level 130. Could you try to execute: ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = 130 Also, if you are using JSON on Azure SQL Database, note that even new databases are created under 120 compatibility level so you should change it if you want to use

Why can I not install SQL Server Express 2016 on Windows 7 Professional 64 bit SP1?

社会主义新天地 提交于 2019-11-30 01:13:06
When trying to install SQL Server 2016 Express in Windows 7 Professional x64 SP1 in VMware I get the following message. What can I do to solve this? As the error message states SQL Server 2016 is not supported in Windows 7. You will have to upgrade to Windows 8 or higher or switch to a Windows Server operating system. Here is a list of all the operating systems (and other hardware and software requirements) in which SQL Server 2016 can be installed. Here is a workaround for users that need SQL 2016 on a Windows 7 development PC. This will allow the developer to develop and manage them by using

Cannot be opened because it is version 852. this server supports version 782 and earlier

落爺英雄遲暮 提交于 2019-11-29 04:02:51
I am using Visual Studio 2017 and SQL Server 2014. While attaching a database file to Visual Studio, I get this error: " " After upgrading the file I used this connection string <connectionStrings> <add name="con" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\binaaelmamorra.mdf;Integrated Security=True;Connect Timeout=30"/> </connectionStrings> It's working fine on my machine, but on the client machine, an error pops up saying Cannot be opened because it is version 852. This server supports version 782 and earlier Though I installed SQL Server 2016 local

OPENJSON does not work in SQL Server?

你说的曾经没有我的故事 提交于 2019-11-28 23:47:01
问题 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. 回答1: Could you check compatibility level on database? OPENJSON is available under compatibility level 130. Could you try to execute: ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = 130 Also, if you are using JSON on Azure SQL Database, note that

How to search SQL column containing JSON array

时光怂恿深爱的人放手 提交于 2019-11-28 12:20:27
I have a SQL column that has a single JSON array: {"names":["Joe","Fred","Sue"]} Given a search string, how can I use SQL to search for a match in the names array? I am using SQL 2016 and have looked at JSON_QUERY, but don't know how to search for a match on a JSON array. Something like below would be nice. SELECT * FROM table WHERE JSON_QUERY(column, '$.names') = 'Joe' Serkan Arslan For doing a search in a JSON array, one needs to use OPENJSON DECLARE @table TABLE (Col NVARCHAR(MAX)) INSERT INTO @table VALUES ('{"names":["Joe","Fred","Sue"]}') SELECT * FROM @table WHERE 'Joe' IN ( SELECT

SQL Server : can you limit access to only one table

ⅰ亾dé卋堺 提交于 2019-11-28 07:33:10
I think the answer is no but I'm looking to give someone access to a SQL Server database but I only really want them to have access to one table. It's easy enough to limit someone to only access one database but have no idea if I can limit to a single table. My thoughts were to create another database with a synonym to the other table and then limit the access to that database but I wondered if someone could think of a better way. I'm also not convinced that it will work as I think there will be a conflict of permissions. Mitch Wheat Yes. exec sp_msforeachtable "DENY SELECT ON ? TO [username];

SQL Server OPENJSON read nested json

ⅰ亾dé卋堺 提交于 2019-11-28 03:29:31
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 number ie I don't want to do anything like this: openjson (@json, '$[0]') or openjson (@json, '$.structures[0]') I had this idea that I could read the values of the top level project objects along with the json string that represents the structures below it, which could then be parsed separately. The problem is that the following code does not work:

SQL Server: Filter output of sp_who2

风流意气都作罢 提交于 2019-11-28 02:37:34
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. Adriaan Stander You could try something like DECLARE @Table TABLE( SPID INT, Status VARCHAR(MAX), LOGIN VARCHAR(MAX), HostName VARCHAR(MAX), BlkBy VARCHAR(MAX), DBName VARCHAR(MAX), Command VARCHAR(MAX), CPUTime INT, DiskIO INT, LastBatch VARCHAR(MAX), ProgramName VARCHAR(MAX), SPID_1 INT, REQUESTID INT ) INSERT INTO @Table EXEC sp_who2 SELECT * FROM @Table WHERE .... And filter on what you require. You could save the results into a temp table , but it

FOR JSON path returns less number of Rows on AZURE SQL

你。 提交于 2019-11-28 02:01:23
I am using AZURE SQL (SQL Server 2016) and creating a query to give me output in JSON object. I am adding FOR JSON PATH at the end of query. When I execute the procedure without adding FOR JSON PATH to the query, I get 244 rows (no of records in my table); but when I execute the procedure by adding FOR JSON PATH I get message 33 rows and also I get JSON object which is truncated. I tested this with different types of queries including simple query selecting only 10 columns, but I always get less number of rows with FOR JSON PATH and JSON object truncated at the end. Here is my query SELECT [Id

how to Convert Table to Json Arrays?

三世轮回 提交于 2019-11-28 00:04:14
I'm using Sql Server 2016 and I want to convert a table to json. I have a simple Table : CREATE TABLE [dbo].[TableTmp]( [Color] [nvarchar](50) NULL, [Type] [nvarchar](50) NULL, [Number] [nvarchar](50) NULL ) ON [PRIMARY] GO INSERT [dbo].[TableTmp] ([Color], [Type], [Number]) VALUES (N'Blue', N'A', N'1') GO INSERT [dbo].[TableTmp] ([Color], [Type], [Number]) VALUES (N'Blue', N'A', N'2') GO INSERT [dbo].[TableTmp] ([Color], [Type], [Number]) VALUES (N'Blue', N'A', N'3') GO INSERT [dbo].[TableTmp] ([Color], [Type], [Number]) VALUES (N'Blue', N'B', N'1') GO INSERT [dbo].[TableTmp] ([Color], [Type]