469,106 Members | 2,096 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Insert Into Column problem ...

Hi Every1,

This is the first time I'm trying to use columns by themselves instead
of using individual values.
And I'm getting an error.

Here is my sql

INSERT INTO PS_CUST_CONTACT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS,
ADDRESS_SEQ_NUM, LAST_MAINT_OPRID, DATE_LAST_MAINT)
SELECT (SETID, CUST_ID, CNTCT_SEQ_NUM, EFF_STATUS, ADDRESS_SEQ_NUM,
LAST_MAINT_OPRID, DATE_LAST_MAINT) FROM PS_CONTACT_CUST WHERE CUST_ID
NOT IN(SELECT CUST_ID FROM PS_CUST_CONTACT)

& the Error is
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near ','.

I've matched all the columns. Second table have extra columns & I
didn't included them because then the columns will not match.
Also I only want to insert the values which are not currently present
in table 1.

Thanks in advance for your help.

Jul 23 '05 #1
2 1238
You don't need the extra parentheses in there.

INSERT INTO PS_CUST_CONTACT
(setid, cust_id, cntct_seq_num, eff_status, address_seq_num,
last_maint_oprid, date_last_maint)
SELECT
setid, cust_id, cntct_seq_num, eff_status, address_seq_num,
last_maint_oprid, date_last_maint
FROM PS_CONTACT_CUST
WHERE cust_id NOT IN
(SELECT cust_id
FROM PS_CUST_CONTACT)

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2
Thanks David for your quick response.
After removing the extra parentheses as you suggested it worked fine.

Thks for your time.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by me | last post: by
6 posts views Thread by pk | last post: by
16 posts views Thread by robert | last post: by
2 posts views Thread by Geoffrey KRETZ | last post: by
9 posts views Thread by cavassinif | last post: by
6 posts views Thread by rn5a | last post: by
1 post views Thread by skanemupp | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.