Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 SQL script Error message

Author  Topic 

avijit_mca
Posting Yak Master

109 Posts

Posted - 2010-07-16 : 00:53:01
Execute SQL Script :
declare @tab varchar(40),@no int,@SQL varchar(max)
set @no= (select COUNT(name) from sys.tables where name not IN ('UserInfo'))
set ANSI_WARNINGS off
while @no >=1
begin

select @tab=name from (select row_number() over (order by name) as Row,name from sys.tables where name not IN ('UserInfo')) as t where t.row=@no
--
begin try
--begin tran
select @tab
exec(' insert into ['+@tab+']
select * from WSS_Content_2010..['+@tab+'] D where d.tp_DeleteTransactionId =0x and
not exists(select * from ['+@tab+'] p where p.id = d.id )')

--commit
end try
begin catch
select 'Execution Not success For Table:' ,@tab, ERROR_MESSAGE() , ERROR_NUMBER ()
end catch
set @no=@no-1
end

Then i link with script.
I want to display all Resulset in catch block.
if i run this query in SSMS it showing error message. but if i pass variable in script it showing only true flag.

any idea how i will show all the error message using script or write all the message in a file. any thing it would be fine for me.

Regards,
avijit
   

- Advertisement -