SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Insert statement and where clause
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dnf999
Constraint Violating Yak Guru

253 Posts

Posted - 06/13/2007 :  04:51:01  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
5531 Posts

Posted - 06/13/2007 :  04:53:57  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
Insert into Test
Select @DB, @DB_Name, @Date, @Quantity 
Where exists(select * from SomeTable where ID  = @ID)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000