Skip to content

Instantly share code, notes, and snippets.

/Azure Secret

Created February 12, 2015 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b49c1e70c8188059be51 to your computer and use it in GitHub Desktop.
Save anonymous/b49c1e70c8188059be51 to your computer and use it in GitHub Desktop.
Deletes fine
CREATE TABLE dbo.ThisWorksFine
(
StupidSK int IDENTITY(1,1) NOT NULL PRIMARY KEY
, BatchId int
, Value nvarchar(50)
);
-- (422500 row(s) affected)
-- 24 seconds
INSERT INTO dbo.ThisWorksFine
(
BatchId
, Value
)
SELECT
10 AS BatchId
, LEFT(C.name,50) AS Value
FROM
sys.columns AS C
CROSS APPLY
sys.columns AS C2;
-- (422500 row(s) affected)
-- 24 seconds
INSERT INTO dbo.ThisWorksFine
(
BatchId
, Value
)
SELECT
30 AS BatchId
, LEFT(C.name,50) AS Value
FROM
sys.columns AS C
CROSS APPLY
sys.columns AS C2
-- (1267500 row(s) affected)
-- 1:24
INSERT INTO dbo.ThisWorksFine
(
BatchId
, Value
)
SELECT
50 AS BatchId
, LEFT(C.name,50) AS Value
FROM
sys.columns AS C
CROSS APPLY
sys.columns AS C2
CROSS APPLY
sys.tables AS T
-- 2112500
SELECT COUNT_BIG(1) AS rc FROM dbo.ThisWorksFine AS TWF
SELECT CAST(CURRENT_TIMESTAMP AS datetime2(7)) AS StartTime;
DELETE TWF
FROM
dbo.ThisWorksFine AS TWF
WHERE
TWF.BatchId = 30;
SELECT CAST(CURRENT_TIMESTAMP AS datetime2(7)) AS StopTime;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment