From 71f4e8072020e9dff3980a926694e610b608a098 Mon Sep 17 00:00:00 2001 From: Scott Sutherland Date: Tue, 21 May 2024 08:29:47 -0500 Subject: [PATCH] Update pesterdb.sql Add trigger that uses global temp tables --- tests/pesterdb.sql | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/pesterdb.sql b/tests/pesterdb.sql index deaafb7..833ce9a 100644 --- a/tests/pesterdb.sql +++ b/tests/pesterdb.sql @@ -677,6 +677,32 @@ if (select count(*) from sys.sql_logins where name like 'SysAdmin_DML') = 0 EXEC sp_addsrvrolemember 'SysAdmin_DML', 'sysadmin'; GO +-- Create a DML trigger that uses Global Temp tables + +USE testdb3; +GO + +CREATE TRIGGER trg_InsertHello +ON NOCList +AFTER INSERT +AS +BEGIN + -- Create a global temporary table + CREATE TABLE ##GlobalTempTable ( + Message NVARCHAR(100) + ); + + -- Insert the word "hello" into the global temporary table + INSERT INTO ##GlobalTempTable (Message) + VALUES ('hello'); + + -- Optionally, you can select from the global temporary table to verify insertion + SELECT * FROM ##GlobalTempTable; + + -- Drop the global temporary table + DROP TABLE ##GlobalTempTable; +END; +GO ------------------------------------------------------------ -- Create Test Keys, Certificates, and Cert Logins