User-1634604574 posted
i have this procedure
ALTER proc [dbo].[INSERT_Brand]
@series varchar(50)=null,
@Brand_name varchar(50)=null,
@Description varchar(50)=null,
@user varchar(50)=null
as begin
--*****************************************
declare @Series_1 varchar(50)
,@series2 varchar(50)
set @Series_1=( select top 1 series from Brand order by ID desc)
set @user='admin'
IF(@Series_1 is not null)
begin
select @Series2=CONCAT('Brand-',RIGHT(@Series_1, CHARINDEX('-', REVERSE(@Series_1)) - 1)+1 )
end
else
begin
SELECT @Series2=CONCAT('Brand-','1')
end
begin try
set nocount on;
declare @trancount int;
set @trancount = @@trancount;
if @trancount = 0
begin transaction
else
save transaction INSERT_Brand;
insert into [dbo].Brand(
series,
Brand_name,
Description
)
values(@Series2,@Brand_name,@Description)
lbexit:
if @trancount = 0
commit;
end try
begin catch
declare @error int, @message varchar(4000), @xstate int,@ErrorProc sysname, @ErrorLine INT;
select @error = ERROR_NUMBER(), @message = ERROR_MESSAGE(), @xstate = XACT_STATE(),@ErrorProc = ERROR_PROCEDURE(),@ErrorLine = ERROR_LINE();
if @xstate = -1
rollback;
if @xstate = 1 and @trancount = 0
rollback
if @xstate = 1 and @trancount > 0
rollback transaction
INSERT INTO ErrorLog (ErrorMsg, ErrorNumber, ErrorProc, ErrorLine) VALUES (@message, @error, @ErrorProc, @ErrorLine)
raiserror ('INSERT_Brand: %d: %s', 16, 1, @error, @message);
end catch
End
here is trigger
CREATE trigger [dbo].[trg_audit_TableName]
ON [dbo].brand
FOR INSERT
AS
declare @get_user varchar(300)
set @get_user=@user(i want to set @get_user get value from this parameter @user from procedure)
insert into tb_log(user)(@user)