Skip to content

Instantly share code, notes, and snippets.

View samirbehara-zz's full-sized avatar

Samir Behara samirbehara-zz

View GitHub Profile
select name, lock_escalation_desc
from sys.tables
ALTER TABLE tablename
SET (LOCK_ESCALATION = DISABLE) -- or TABLE or AUTO
--Returns detailed information about missing indexes
SELECT * FROM sys.dm_db_missing_index_details
--Returns information about what missing indexes are contained in a specific missing index group
SELECT * FROM sys.dm_db_missing_index_groups
--Returns summary information about groups of missing indexes
SELECT * FROM sys.dm_db_missing_index_group_stats
SELECT name AS IndexName,
STATS_DATE(object_id, stats_id) AS LastStatisticsUpdate
FROM sys.stats
WHERE object_id = OBJECT_ID('TABLENAME')
and name ='INDEXNAME';
--ISJSON() - To verify that the text has valid JSON data
DECLARE @json nvarchar(max)
SET @json =N'
{
"Person": [
{
"FirstName": "Gustavo",
"LastName": "Achong",
"AccountNumber": "AW00029484",
"ModifiedDate": "2014-09-12T11:15:07.263"
--ISJSON() - To verify that the text has valid JSON data
DECLARE @json nvarchar(max)
SET @json =N'
{
"Person": [
{
"FirstName": "Gustavo",
"LastName": "Achong",
"AccountNumber": "AW00029484",
"ModifiedDate" "2014-09-12T11:15:07.263"
-- JSON_VALUE Demonstration to pull one scalar value from the JSON data
DECLARE @json nvarchar(max)
SET @json =N'
{
"Person": [
{
"FirstName": "Gustavo",
"LastName": "Harris",
"AccountNumber": "AW00029484",
"ModifiedDate": "2014-09-12T11:15:07.263"
-- JSON_QUERY Demonstration to extract an object or array from the JSON data
DECLARE @json nvarchar(max)
SET @json =N'
{
"Person": [
{
"Name": {
"FirstName": "Catherine",
"LastName": "Abel"
},
-- JSON_MODIFY Demonstration to update the value of a property in JSON string
DECLARE @json nvarchar(max)
SET @json =N'
{
"Person": [
{
"Name": {
"FirstName": "Catherine",
"LastName": "Abel"
},
// Entity Framework Query
_context.Titles.Where (t => t.ListCode.Trim() == buildTitle.ListCode)
// Corresponding Query fired against SQL Server
DECLARE @p0 VarChar(3) = 'BO'
SELECT [t0].[Titlecode], [t0].[ZLineNumber]
FROM [Titles] AS [t0]
WHERE LTRIM(RTRIM([t0].[ListCode])) = @p0