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 2005 Forums
 Transact-SQL (2005)
 Insert statement and where clause

Author  Topic 

dnf999
Constraint Violating Yak Guru

253 Posts

Posted - 2007-06-13 : 04:51:01
Hi can I use a where clause with an insert statement using variables?

i.e.
insert into Test Table
(@DB, @DB_Name, @Date, @Quantity)
where ID = @ID

result:
ID, DB, DB_Name, Date, Quantity
ID1, 1, test1 , 12-June, 1000


Thanks

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-13 : 04:53:57
[code]Insert into Test
Select @DB, @DB_Name, @Date, @Quantity
Where exists(select * from SomeTable where ID = @ID)[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -