If you get error message 4982 in SQL Server, it’s because your source table doesn’t have a constraint that restricts data to only the range supported by the partition that you’re trying to switch to.
Continue readingTag: mssql
How to Import a JSON File into a SQL Server Table
If you have a JSON document, there are several ways you could go about getting it into SQL Server.
If it’s a small document, you could copy and paste its contents. If it’s a larger document (or even a small one), you might want to import the whole file.
This article presents an example of importing a JSON file into a SQL Server database.
Continue readingHow to Insert JSON into a Table in SQL Server
If you have a JSON document that you need to insert into a table in a SQL Server database, the OPENJSON()
function could be just what you need.
OPENJSON()
is a table-valued function that returns JSON in tabular format. That is, it converts your JSON into a tabular result set consisting of rows and columns. Therefore, it enables you to insert it into a table.
What is STATISTICS TIME in SQL Server?
In SQL Server, you can use the SET STATISTICS TIME
statement to display the time it takes to execute a T-SQL statement.
More specifically, it returns the number of milliseconds required to parse, compile, and execute each statement.
When SET STATISTICS TIME
is ON
, the time statistics for a statement are displayed. When OFF
, the time statistics are not displayed.
The setting of SET STATISTICS TIME
is set at execute or run time and not at parse time.
SQL Server Error 113: Missing end comment mark ‘*/’
SQL Server error message 113 occurs when you omit a closing comment mark.
This can occur when you open a comment but forget to close it. It can also occur when you accidentally type an opening comment.
There may also be odd occasions where you get this error due to other factors, such as the way your SQL utility handles certain keywords etc.
Continue readingFind Out if a Table is Partitioned in SQL Server (T-SQL)
If you need to find out if a table has been partitioned in SQL Server, you can run a join against the sys.tables
, sys.indexes
, and sys.partition_schemes
views.
How to Fix: JSON_VALUE Returns NULL with Long Strings (SQL Server)
If you’re using JSON_VALUE()
to return values consisting of a long string, you might find that it returns NULL
instead of the actual value.
Or, you might be getting an error.
Continue readingWhat is STATISTICS PROFILE in SQL Server?
In SQL Server, you can use the SET STATISTICS PROFILE
statement to display the profile information for a T-SQL statement.
STATISTICS PROFILE
works for ad hoc queries, views, and stored procedures.
When STATISTICS PROFILE
is set to ON
, each executed query returns its regular result set, followed by an additional result set that shows a profile of the query execution.
What is STATISTICS IO in SQL Server?
In SQL Server, you can use the SET STATISTICS IO
statement to generate detailed information about the amount of disk activity generated by a T-SQL statement.
In graphical tools like SSMS and Azure Data Studio, you can view this information in the Messages tab.
Continue readingHow to Fix “A correlation name must be specified for the bulk rowset in the from clause.” in SQL Server
If you encounter error Msg 491, Level 16 “A correlation name must be specified for the bulk rowset in the from clause” in SQL Server, it’s probably because you’re trying to read a file without using a correlation name.
Continue reading