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 |
Mng
Yak Posting Veteran
59 Posts |
Posted - 2011-01-10 : 07:44:30
|
Hi,In a stored procedure, how can i catch if sqlstatement returns more than one row ? DECLARE @courseid intSET @courseid = (select COURSE_ID from CATEGORY_COURSE where groupid = 'as_rew')The above example works good, if the query returns one value.If it returns more than 10 values...how can i catch ?can we declare array variables ? Plz help me |
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2011-01-10 : 08:10:38
|
DECLARE @courseid intSET @courseid = (select TOP 1 COURSE_ID from CATEGORY_COURSE where groupid = 'as_rew' ORDER BY SomeCol)- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-10 : 11:16:00
|
for catching all values returned you need table variables.DECLARE @temp table( @courseid int)INSERT @tempselect COURSE_ID from CATEGORY_COURSE where groupid = 'as_rew' ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|