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 |
|
goranzr85
Starting Member
5 Posts |
Posted - 2011-04-19 : 07:04:24
|
| is this possible?create procedure mySP@param1 int,@param2 int, @param3 int...declare @br intdeclare @value nvarchar(50)set @br=0set value=""while(br<3)beginset @value=@value+ @param+'br'// i know that isn't correct sintax//can do it in some other way?//if br=1 then do next set @value=@value+ @param1 end |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-04-19 : 07:14:39
|
| No - you can't reference the parameter name.you couldselect pnum = 1, val = @param1into #aunion allselect pnum = 2, val = @param2union allselect pnum = 3, val = @param3declare @br intdeclare @value nvarchar(50)set @br=0set @value=""while @br<3)beginselect @br = @br + 1select @value = @value + val + 'br' from #a where pnum = @brendbut you might as well doselect @value = @param1 + 'br + @param2 + 'br' + @param3 + 'br'unless you can pass the values as a table variable.Another option isselect pnum = 1, val = @param1into #aunion allselect pnum = 2, val = @param2union allselect pnum = 3, val = @param3select @value = ( select val + 'br' from #a for xml path('') )==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|