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 |
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2004-09-17 : 20:24:12
|
| I have a stored procedure and the declarations are like @through_date datetime, @status varchar(20), @instat_id int OUTPUT When I insert a record to the tbl_reint table with the through_date and status a auto incremental value instat_id is created and now I need to return this value likeselect @instat_id =@@identitybut how will I check the return value with the query analyzerDeclare @temp intselect @temp = execute usp_reater '12/12/2004','N'print @temp |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-09-17 : 22:05:34
|
| I'm pretty sure its:Declare @temp intexecute usp_reater '12/12/2004','N', @tempprint @tempCorey |
 |
|
|
gpl
Posting Yak Master
195 Posts |
Posted - 2004-09-18 : 04:52:06
|
Ive always done Declare @temp intexecute usp_reater '12/12/2004','N', @temp Outputprint @temp Graham |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-09-18 : 11:48:52
|
| oops.... you're right... i don't ever actually use outputs so i forget...Corey |
 |
|
|
sqllearner
Aged Yak Warrior
639 Posts |
Posted - 2004-09-18 : 21:44:57
|
| got it right.. thanks guys. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-09-19 : 01:41:27
|
| Seventhnight:"i don't ever actually use outputs so i forget"You'll be in trouble with the thought police for not returning your error information that way!Kristen |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-09-19 : 10:46:51
|
I don't have errors Corey |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2004-09-19 : 16:03:38
|
| My 2 cents on style... When a proc has a lot of paramters, I like to name 'em all instead of relying on position:DECLARE @instat_ID INTDECLARE @returnvalue INTEXEC @returnvalue = usp_reater @through_date='12/12/2004',@status='N', @instat_id=@instat_id OUTPUTprint @returnvalueprint @instat_idSam |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-09-20 : 09:12:54
|
| Probably better to always name them - some blighter is bound to bung an extra parameter "in the middle" ...Kristen |
 |
|
|
|
|
|