Kenneth Singer


Technical Article

Auto generate sp's for any table * usp_create_sps

If you've ever been stuck having to write stored procedures to support an application, check this script out.  This script will automatically generate seperate parameter driven select, insert, delete, and update stored procedures.  Simply call these stored procedures from your application, passing parameters.  This stored procedure requires only one parameter; table name.  Creates scripts with […]

1 (1)

You rated this post out of 5. Change rating

2002-02-21

327 reads

Technical Article

DATEMY - Covnerts and validates MM/YY, MM/YYYY

If you've ever needed a convenient and quick way to convert/validate what could possibly be a mm/yy or mm/yyyy date to mm/dd/yyyy (date of month is 01) check out this custom function.  Eg:  select dbo.datemy('04/02') outputs smalldatetime '2002-04-01 00:00:00'.  Select dbo.datemy('04/2002') outputs the same smalldatetime '2002-04-01 00:00:00'.

You rated this post out of 5. Change rating

2002-02-15

871 reads

Technical Article

Send notifications on job STEP failures (trigger)

Have you ever wanted to have SQL note a failure on a step, yet continue running the job.  I found it to be annoying that you have to fail (and end) a job in order to send a message to an operator.  I have processes that run at off times, I want to know when […]

5 (2)

You rated this post out of 5. Change rating

2002-02-13

2,282 reads

Blogs

SQL Server Time Bombs

By

Common Reasons for Emergency SQL calls If you are a production DBA (or Accidental...

Book Review: A Radical Enterprise

By

I grabbed this book over the 2024 holiday season as it was on sale...

Advice I Like: Investing and Growing Rich

By

Investing small amounts of money over a long time works miracles, but no one...

Read the latest Blogs

Forums

DBCC Clone Database Failing on SQL 2022

By amishraval

When running clone sql is changing one specific table to History table and its...

What is time?

By Louis Davidson (@drsql)

Comments posted to this topic are about the item What is time?

KB5046856 fails to install

By webrunner

Hello experts, The following SQL update is failing to install on some of our...

Visit the forum

Question of the Day

Rows estimation with OPENJSON

Consider the following script for a Sql Server database with Compatibility Level at least 130 (Sql Server 2016):

create table tjson (
id int primary key,
j1 varchar(max),
j2 varchar(max),
j3 varchar(max));

insert into tjson (id, j1, j2, j3) 
values 
(1,
'[{"c11":"value11A", "c12":"value12A"},{"c11":"value11B", "c12":"value12B"}]',
'[{"c21":"value21A", "c22":"value22A"},{"c21":"value21B", "c22":"value22B"}]',
'[{"c31":"value31A", "c32":"value32A"},{"c31":"value31B", "c32":"value32B"}]');
How many rows does the Query Optimizer estimate for the following query?
select id, c1.c11, c2.c21, c2.c22, c3.c31, c3.c32
from tjson
cross apply openjson(j1) with(
c11 varchar(50) '$.c11',
c12 varchar(50) '$.c12') c1
cross apply openjson(j2) with(
c21 varchar(50) '$.c21',
c22 varchar(50) '$.c22') c2
cross apply openjson(j3) with(
c31 varchar(50) '$.c31',
c32 varchar(50) '$.c32') c3;
 

See possible answers