41 questions
2
votes
1
answer
4k
views
JSON_VALUE path "$" returns NULL when it contains data
I have a column data consisting of {"name":["John","Peter"],id:["20","30"]}
If I do
SELECT JSON_VALUE(data,'$.name[0]') from table
it returns John ...
30
votes
8
answers
20k
views
Restore database in docker container
Getting an error below when restoring a AdventureWorks2017 database within a docker container.
Running SQL Server 2019 CTP 2.0 (mcr.microsoft.com/mssql/server:vNext-CTP2.0-ubuntu)
Both backup and ...
7
votes
2
answers
5k
views
Unexpected @@rowcount behavior inside an UDF in MS SQL 2019
here's my sample code
drop function rowcount_test
go
CREATE FUNCTION dbo.rowcount_test () RETURNS INT AS
BEGIN
DECLARE @v INT
SELECT @v = 1
return @@ROWCOUNT
END
GO
grant exec on dbo....
7
votes
2
answers
6k
views
Quiet (unattended) install of SQL Server Express LocalDb 2019
With SQL Server Express LocalDb 2012 (Microsoft MSI download) it was possible to do an unattended install from a command line:
msiexec /i SqlLocalDB.msi /qn IACCEPTSQLLOCALDBLICENSETERMS=YES
This ...
4
votes
1
answer
593
views
JSON_MODIFY is not working properly in SQL Server 2017
Here is my code:
DECLARE @info NVARCHAR(MAX) = '{"searchQuery":{"reportType":"ReportedHcEcg"},"pageQuery":{"pageNumber":1,"pageSize":10,"sortColumnName":"Urgent, UploaDateTime","sortOrder":"Desc"}}'
...
0
votes
0
answers
370
views
Powershell error message: Failure | The network path was not found
I am relatively new to Powershell, and I got a script to use to restore database in SQL Server 2019.
I was running this bottom Powershell script on my new VM, and got bottom error message.
This is ...
7
votes
1
answer
1k
views
SQL Server machine learning services r version 3.5
According to this link, SQL Server machine learning service's highest R version is 3.3. Does anyone know when one can upgrade to version 3.5 or later?
Or is my only option to switch to sql server ...
3
votes
2
answers
4k
views
How to determine if given table is memory optimized?
Good morning,
My first question is how to determine if tables created in MS SQL Server are memory optimized. I have some tables and I don't remember if some of them I created in-memory optimized or ...
2
votes
2
answers
103
views
SQL Server: Transform arrays of JSON objects into table format
Following is the given JSON data:
DECLARE @Jdata NVARCHAR(MAX) =
'{
"EmployeeDetails": {
"BusinessEntityID": 3,
"NationalIDNumber": 509647174,
"...
1
vote
1
answer
532
views
Showing converted Base64 (from hex) in an existing SQL Server 2019 view
I do voluntary work at an animal shelter. We have an application which uses a SQL Server 2019 database. I have created a view that includes a varbinary(max) column. The value in this column is a ...
1
vote
1
answer
286
views
INNER JOIN involving RAND(...NEWID()) returns unexpected number of rows
I want to generate some sample data with random values.
I have a mini table with 5 rows, ids from 1 to 5 with some text for every row.
Then I want to generate 65536 rows - first column has value 1 for ...
1
vote
2
answers
20k
views
Getting Error Installing SQL Server 2019 in Windows 11
I am trying to install SQL Server 2019 in Windows 11. I am getting the following error for database engine and SQL Server Replication:
Detailed results:
Feature: Database ...
0
votes
1
answer
4k
views
SQL Query on Json object inside multiple JSON objects
I have the below Json string. I need to write a query to get the TP records. Without providing the index value, we need get the result.
{
"S": [
{
"Name": "Project1",
"SP": [
...
0
votes
1
answer
281
views
How to prevent user (having db_datawriter) from being able to connect via management studio?
I have a windows sql user that is assigned db_datawriter role on a db.
Presently the user can connect to the database via management studio and make changes to the data in the database.
Also, he can ...
0
votes
4
answers
587
views
SQL count the number of comma-separated string match in another string [closed]
I have a table in SQL Server with two columns as shown here, all number are comma-separated:
IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL
DROP TABLE #TempTable
CREATE TABLE #TempTable
(
...
0
votes
0
answers
69
views
Update where not exactly the same [duplicate]
If I don't want to treat an empty string and NULL as being the same value, is there a cleaner way to write the following:
-- @name and SomeTable.Name are varchar(10) NULL
update SomeTable set Name = @...
0
votes
1
answer
303
views
sp_refreshsqlmodule is failing with UNION, INTERSECT or EXCEPT operator must have an equal number of expressions error
I have written one stored procedure where I have added UNION like this:
SELECT *,SysStartTime, SysEndTime FROM dbo.FirstTable WHERE Id = @Id
UNION
SELECT * FROM history.FirstTable WHERE Id = @Id
...
0
votes
3
answers
7k
views
SQL Server 2019 > Agent Job execute > Error 'Culture is not supported'
Within the Job History logs - Error on Step 1 : Culture is not supported. Parameter name: culture 3072 (0x0c00) is an invalid culture identifier.
Prior to this issue, I changed the server (MS SQL ...
0
votes
1
answer
492
views
Writing a query to generate some scripts to rename some columns in entire database
I have a SQL Server 2019 database (a big one). This database has about 3000 columns and about 200 tables and for each table we have at least 3 stored procedures.
Anyway we have some columns in this ...
0
votes
2
answers
2k
views
Unpack all arrays in a JSON column SQL Server 2019
Say I have a table Schema.table with these columns
id | json_col
on the forms e.g
id=1
json_col ={"names":["John","Peter"],"ages":["31","40"...
-1
votes
1
answer
3k
views
'String or binary data would be truncated' without any data exceeding the length
Yesterday suddenly a report occurred that someone was not able to get some data anymore because the issue Msg 2628, Level 16, State 1, Line 57 String or binary data would be truncated in table 'tempdb....