I have created the following stored procedure in SQL:
CREATE procedure [dbo].[sp_trip_number]
@Table_Name nvarchar(100), @Trip_Number int output as begin set nocount on begin transaction DECLARE @DynamicSQL NVARCHAR(1000) DECLARE @New_Trip_Number int SET @DynamicSQL='INSERT INTO ' + @Table_Name + ' DEFAULT VALUES' + ';' + 'SELECT'+ @New_Trip_Number+ +'=' + 'SCOPE_IDENTITY()'
EXEC (@DynamicSQL )
SET @Trip_Number = @New_Trip_Number
I am passing a table name as one parameter, but I want scope identity as an output into the second parameter. How can I do this?
December 10, 2008 7:54 PM
December 11, 2008 3:54 AM