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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select question

Author  Topic 

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2006-05-29 : 09:38:16
Hi,

i have a select statement below;

select [fTime] from [TEMP] where [pID] = 11 or [pID] = 12 or [pID] = 13 or [pID] = 14

and this statement always generates 4 results. I want to get those result into 4 different variables, how can i do this?

thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-29 : 09:43:12
Select @var1=[fTime] from [TEMP] where [pID] = 11
Select @var2=[fTime] from [TEMP] where [pID] = 12
.
.

Select @var1, @var2

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-05-29 : 09:54:39
or

select @var1 = Case When [pID] = 11 Then [fTime] Else @var1 End
@var2 = Case When [pID] = 12 Then [fTime] Else @var2 End
@var3 = Case When [pID] = 13 Then [fTime] Else @var3 End
@var4 = Case When [pID] = 14 Then [fTime] Else @var4 End
From [TEMP]



If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page
   

- Advertisement -