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.
| Author |
Topic |
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-12-10 : 10:57:18
|
| I have declared some variables on the top then I have try catch. Then after the catch I have an insert statement to log into a logTable. Why the variable I declared before the begin try is not accessible after the end catch? |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-12-10 : 13:33:55
|
| what are you doing inside catch? is there a transaction which is rolledback inside catch? |
 |
|
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-12-10 : 13:49:28
|
| alter procedure [dbo].[usp_sendmail](@user varchar(100),@runDate datetime,@body varchar(500)set @user=system_userset @runDate = getdate()set @body = @user + @runDate + 'record has been updated.'begin try update statmentend trybegin catch end catch-- now keep a log of send emailanother insert statement with variables declared above ) |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-12-10 : 14:51:56
|
quote: Originally posted by doran_doran alter procedure [dbo].[usp_sendmail](@user varchar(100),@runDate datetime,@body varchar(500)set @user=system_userset @runDate = getdate()set @body = @user + @runDate + 'record has been updated.'begin try update statmentend trybegin catch end catch-- now keep a log of send emailanother insert statement with variables declared above )
you're going to error out on the line in red above. need to cast the datetime to a varchar |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|