So with SQL Server 2008 we have output clause available inside the query that means we can access the inserted, deleted or updated value form the output clause inside a Stored Procedure and we need not to write a trigger
Ex.
Suppose we have a user table on inserting the data we need to insert the same value to a table type variable, we can accomplish this task as given below:
DECLARE @User TABLE (ID INT, Name VARCHAR(50), Age INT, Is_Active BIT, CREATE_DATE DATETIME)
INSERT INTO [User] (Name, Age, Is_Active, CREATE_DATE)
OUTPUT inserted.* INTO @User VALUES ('TESTING', '26', 1, GETDATE())
SELECT * FROM @User
No comments:
Post a Comment