469,601 Members | 2,383 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,601 developers. It's quick & easy.

how to use select statement in insert query

hi my self avi
i want to copy data from one table to other table,by giving certain
condition and i want o use insert statement .in this i want to pass some
value directly and some value from select statement , if i try i ll get
error i.e all column of destination table (i.e in which i want to insert
data) should match with all columns in values column some thing like
this.
plz give me some helpful suggetion on this

Jul 20 '05 #1
1 9924

"avinash" <pa***********@rediffmail.com> wrote in message
news:f9******************************@localhost.ta lkaboutdatabases.com...
hi my self avi
i want to copy data from one table to other table,by giving certain
condition and i want o use insert statement .in this i want to pass some
value directly and some value from select statement , if i try i ll get
error i.e all column of destination table (i.e in which i want to insert
data) should match with all columns in values column some thing like
this.
plz give me some helpful suggetion on this


Something like this?

insert into dbo.Table1
(col1, col2, col3, col4)
select 'A', co11, 7, col8
from dbo.Table2
where...

In the SELECT statement, you can mix constant values ('A' and 7) with column
values (col1 and col8) - I think this is what you want to do, if I
understood you correctly. If this doesn't help, then I suggest you post
CREATE TABLE statements for both tables, and the INSERT statement you're
trying to make work, as that will avoid any confusion and guesswork.

Simon
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Phil Powell | last post: by
reply views Thread by Christopher Key | last post: by
11 posts views Thread by Jeff Sandler | last post: by
3 posts views Thread by Tcs | last post: by
4 posts views Thread by JMCN | last post: by
2 posts views Thread by paulmitchell507 | last post: by
6 posts views Thread by BobRoyAce | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.