April 17, 2013 at 4:05 am
A string contains 3,4 suppose I want to store 3 in one parameter and 4 in another parameter similar in c# like arr[0] and arr[1]? how can i achieve it
April 17, 2013 at 7:34 am
rama.king127 (4/17/2013)
A string contains 3,4 suppose I want to store 3 in one parameter and 4 in another parameter similar in c# like arr[0] and arr[1]? how can i achieve it
Think outside the box, the sql way like this...
set nocount on;
declare @sqlArray table (id int identity(1,1), item int)
insert into @sqlArray(item)
select 3 union all
select 4;
declare @x int=1, @arrayLength int, @curItem int
select @arrayLength=MAX(id) from @sqlArray;
--now loop thru your array =)
while @x <= @arrayLength begin
select @curItem = item from @sqlArray where id=@x;
print @curItem;
set @x= @x+1;
end
April 17, 2013 at 7:42 am
You may want to have a read about custom types.
April 17, 2013 at 4:22 pm
haiao2000 (4/17/2013)
rama.king127 (4/17/2013)
A string contains 3,4 suppose I want to store 3 in one parameter and 4 in another parameter similar in c# like arr[0] and arr[1]? how can i achieve itThink outside the box, the sql way like this...
set nocount on;
declare @sqlArray table (id int identity(1,1), item int)
insert into @sqlArray(item)
select 3 union all
select 4;
declare @x int=1, @arrayLength int, @curItem int
select @arrayLength=MAX(id) from @sqlArray;
--now loop thru your array =)
while @x <= @arrayLength begin
select @curItem = item from @sqlArray where id=@x;
print @curItem;
set @x= @x+1;
end
Gosh, no. Think outside the box. 😉 Don't use RBAR for this.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 17, 2013 at 4:24 pm
rama.king127 (4/17/2013)
A string contains 3,4 suppose I want to store 3 in one parameter and 4 in another parameter similar in c# like arr[0] and arr[1]? how can i achieve it
Will you always be passing just 2 parameters like this?
--Jeff Moden
Change is inevitable... Change for the better is not.
April 17, 2013 at 5:42 pm
Also consider Table Value Parameters or some other kind of list shredding method.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply