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
 Transact-SQL (2000)
 How will insert a variable into a table

Author  Topic 

ranjeetsingh_6
Posting Yak Master

125 Posts

Posted - 2006-07-14 : 03:43:55
Hi
I declare a variable and set this value. again i want to insert this value in another table

How I do this task ? I am using this query

declare @name varchar(50)

set @name='select name from sal where salary=1000'

insert into record(name) values(@name)


Ranjeet Kumar Singh

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-07-14 : 03:51:09
Change it to this...

declare @name varchar(50)

select @name = name from sal where salary=1000

insert into record(name) values(@name)


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-07-14 : 05:37:49
you can also insert direct into table without going through variable
insert into record(name)
select name
from sal
where salary = 1000



KH

Go to Top of Page

ranjeetsingh_6
Posting Yak Master

125 Posts

Posted - 2006-07-14 : 06:41:24
Hi

Thanks To you problem have solved

Ranjeet Kumar Singh
Go to Top of Page
   

- Advertisement -