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 |
sign_seventh
Yak Posting Veteran
66 Posts |
Posted - 2006-06-05 : 23:25:16
|
hi,i have a select query..SELECT @id = JBO_JOB_OPPORTUNITY_ID FROM OPPORTUNITIES where JBO_TITLE = 'title'how can i get the each value of @id?. pass it to another variableand then i have to print it.ex. set @idprint =(@idprint +','+ (CAST(@id as varchar))print @idprintoutput-----1, 2, 3---- |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-05 : 23:38:58
|
Is this what you want ?SELECT @id = ''SELECT @id = @id + JBO_JOB_OPPORTUNITY_IDFROM OPPORTUNITIES WHERE JBO_TITLE = 'title' KH |
|
|
sign_seventh
Yak Posting Veteran
66 Posts |
Posted - 2006-06-05 : 23:52:19
|
how about putting comma in every id, @id is numeric and not varchar |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-05 : 23:56:56
|
sorry.. missed out that pointSELECT @id = ''SELECT @id = @id + convert(varchar(10), JBO_JOB_OPPORTUNITY_ID) + ','FROM OPPORTUNITIES WHERE JBO_TITLE = 'title'select @id = left(@id, len(@id) - 1) KH |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-06 : 00:10:02
|
quote: Originally posted by sign_seventh how about putting comma in every id, @id is numeric and not varchar
You mean JBO_JOB_OPPORTUNITY_ID is numeric not varchar ? KH |
|
|
CSK
Constraint Violating Yak Guru
489 Posts |
Posted - 2006-06-06 : 01:06:53
|
Try this oneDeclare @tit varchar(100)Declare @cnt intSelect @cnt =1While (SELECT count(*) FROM OPPORTUNITIES where JBO_TITLE = 'title') >= @cntBegin SELECT @id = JBO_JOB_OPPORTUNITY_ID FROM OPPORTUNITIES where JBO_TITLE = 'title' set @idprint =(@idprint +','+ (CAST(@id as varchar)) Select @cnt = @cnt+1EndThanksKK |
|
|
sign_seventh
Yak Posting Veteran
66 Posts |
Posted - 2006-06-06 : 01:30:34
|
ei guys.. thnxs for d help |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-06 : 03:07:50
|
Note that if the concatenated string length exceeds 8000 characters, then you may not have full value. Where do you want to show the data?MadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|