Skip to content

Commit

Permalink
Update pesterdb.sql
Browse files Browse the repository at this point in the history
Add trigger that uses global temp tables
  • Loading branch information
nullbind authored May 21, 2024
1 parent 80a3223 commit 71f4e80
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/pesterdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 71f4e80

Please sign in to comment.