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
 General SQL Server Forums
 New to SQL Server Programming
 Insert Problem

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-06-05 : 09:47:56
sri writes "Hi I am tying to insert using select statement
for eg:-

v1 := 30;
v2 := 34;

insert into tablename
Values(v1,v2,(select * from tablename);
when I try to compile this it gives me error as right parenthisis missing.
please help.

sri"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-05 : 09:52:36
Insert into tablename(columns)
Select v1,v2,* from tablename

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-06-06 : 02:15:22
for correct field mapping, enumerate the columns, avoid using *, this saves you the trouble when the schema changes on the destination but not source or vice versa

--------------------
keeping it simple...
Go to Top of Page

sri_kumar
Starting Member

1 Post

Posted - 2006-06-06 : 13:21:46
Hi madhivanan
insert into t1
values(select v1,v2,'name',count(*) from t2 where n_id=(select * from t3);

I tried this but it gives me error as PL/SQL: ORA-00936: missing expression

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-06-06 : 21:43:28
"PL/SQL: ORA-00936"

sri_kumar, this is a MS SQL Server forum. Please post your question over at Oracle Forumn like dbforums.com or orafaq.com


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-07 : 01:52:00
If you use Oracle try at Oracle forums
See if this works

insert into t1(col1,col2,col3,col4)
select v1,v2,'name',count(*) from t2 where n_id=(select * from t3);



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -