I have a SPROC like this in SQL server which will split a concatenated string ([var1][var2]) and return 2 result set, how do I pass each individual item from the result sets into another @var in my SProc so that I can do this, thanks:
SET @var3 = (select [var1]+[var2]) --Join the result sets values and assign it to another variable
from ...where...
Result sets:
e.g
resultset
----
tbl1
----
[var1]
resultset
----
tbl1
----
[var2]
Query that splits the concatenated string into it's parts:
declare @Str as varchar(100)
set @Str = '[Var1][Var2]'
while (@Str <> '') begin
select LEFT(@Str, CHARINDEX(']', @Str)) as resulttbl
set @Str = SUBSTRING(@Str, CHARINDEX(']', @Str) + 1, LEN(@Str))
end