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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to pick into a variable from SQL statement

Author  Topic 

jotmenow
Starting Member

12 Posts

Posted - 2006-10-06 : 16:52:15
dear all

Any one of you know the syntax how to select a value into a variable from a simple sql statement.

thanks in advance

Ajay

.

Hommer
Aged Yak Warrior

808 Posts

Posted - 2006-10-06 : 16:57:43
declare @var1 as varchar(10)
select @var1 = 'My string'

or
select @var1 = mytable.myfield where ID= 123
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-10-07 : 01:38:52
select @var1 = mytable.myfield FROM mytable where ID= 123



Kristen
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-10-07 : 07:56:46
OR
Make sure your query returns only one values

Set @var1 = (Select mytable.myfield from mytable where id =123)


Chirag
Go to Top of Page
   

- Advertisement -