Dear All,
this is my coding which inserts some value into User_log table and returns @identity value .
please help me.
thanks in adv.
Declare @NewDB varchar(max);
SET @NewDB='ta.dbo.user_log ( CLIENT_ID,USER_ID,USER_NAME,LOGIN_TIME)'
DECLARE @sqlQueryUserLogId nvarchar(MAX),@UserLogId bigint
DECLARE @ParmDefinitionUserLogId nvarchar(500);
SET @sqlQueryUserLogId='insert into '+ @NewDB+' values( User_Name=''' + @User_Name + ''' ,User_ID=''' + @User_Id + ''' , Client_Id='''+cast(@Client_Id as varchar(20))+''',LOGIN_TIME=GetDate() )';
SET @ParmDefinitionUserLogId= N'@UserLogId bigint OUTPUT'
EXEC sp_executesql @sqlQueryUserLogId,@ParmDefinitionUserLogId, @UserLogId=@@IDENTITY OUTPUT
SET @UserLogId=@@