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 |
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2009-06-01 : 12:46:43
|
Why the following code generates error?BEGIN TRY create procedure foo as select getdate()END TRYBEGIN CATCH select 'err'END CATCH ------------------------I think, therefore I am - Rene Descartes |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-01 : 13:40:58
|
create procedure cannot be combined with any other commands No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2009-06-01 : 13:47:40
|
Okay, thank you - webfred.------------------------I think, therefore I am - Rene Descartes |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-01 : 13:54:42
|
can i ask what you're trying to implement by above code? |
 |
|
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2009-06-01 : 14:03:21
|
quote: Originally posted by visakh16 can i ask what you're trying to implement by above code?
I am just trying to create a proc.1. I know I can use IF EXISTS ….DROP AND THEN CREATE. But for some reason if this code fails I need to know. 2. I can not wrap the SP definition in a string (that could solve my problem) because the proc has lost of double and single quotes. I am thinking of using @@EROR------------------------I think, therefore I am - Rene Descartes |
 |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-06-01 : 15:03:12
|
maybe check for existence after the CREATE statement batch. If it fails for whatever reason the @@error code may not even execute.Be One with the OptimizerTG |
 |
|
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2009-06-01 : 15:06:51
|
quote: Originally posted by TG maybe check for existence after the CREATE statement batch. If it fails for whatever reason the @@error code may not even execute.
That's a good suggestion. Thanks.------------------------I think, therefore I am - Rene Descartes |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-06-02 : 02:10:20
|
quote: Originally posted by ravilobo
quote: Originally posted by visakh16 can i ask what you're trying to implement by above code?
I am just trying to create a proc.1. I know I can use IF EXISTS ….DROP AND THEN CREATE. But for some reason if this code fails I need to know. 2. I can not wrap the SP definition in a string (that could solve my problem) because the proc has lost of double and single quotes. I am thinking of using @@EROR------------------------I think, therefore I am - Rene Descartes
Refer this to know how single quotes work in sqlhttp://sqlblogcasts.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspxMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|