Skip to content

Commit 5a1dc9d

Browse files
committed
#3356 Small change to the temp table creation
1 parent 5f337bd commit 5a1dc9d

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

sp_Blitz.sql

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,14 @@ AS
299299

300300
IF ISNULL(@SkipValidateLogins, 0) != 1 /*If @SkipValidateLogins hasn't been set to 1 by the caller*/
301301
BEGIN
302-
IF OBJECT_ID(N'tempdb..#ValidateLoginsTest') IS NULL
303-
BEGIN
304-
CREATE TABLE #ValidateLoginsTest
305-
(
306-
[SID] varbinary(85)
307-
,[NT_Login] sysname
308-
);
309-
END;
302+
IF OBJECT_ID(N'tempdb..#ValidateLoginsTest') IS NOT NULL
303+
EXEC sp_executesql N'DROP TABLE #ValidateLoginsTest;';
304+
305+
CREATE TABLE #ValidateLoginsTest
306+
(
307+
[SID] varbinary(85)
308+
,[NT_Login] sysname
309+
);
310310

311311
BEGIN TRY
312312
INSERT INTO #ValidateLoginsTest
@@ -316,16 +316,14 @@ AS
316316
)
317317
EXEC sp_validatelogins;
318318

319-
SET @SkipValidateLogins = 0 /*We can execute sp_validatelogins*/
319+
SET @SkipValidateLogins = 0; /*We can execute sp_validatelogins*/
320320
END TRY
321321
BEGIN CATCH
322-
SET @SkipValidateLogins = 1 /*We have don't have execute rights or sp_validatelogins throws an error so skip it*/
322+
SET @SkipValidateLogins = 1; /*We have don't have execute rights or sp_validatelogins throws an error so skip it*/
323323
END CATCH;
324324

325325
IF OBJECT_ID(N'tempdb..#ValidateLoginsTest') IS NOT NULL
326-
BEGIN
327-
DROP TABLE #ValidateLoginsTest;
328-
END;
326+
EXEC sp_executesql N'DROP TABLE #ValidateLoginsTest;';
329327
END; /*Need execute on sp_validatelogins*/
330328

331329
IF ISNULL(@SkipModel, 0) != 1 /*If @SkipModel hasn't been set to 1 by the caller*/

0 commit comments

Comments
 (0)