Monday, May 21, 2012

Want to insert a row taking from the same table

I have a table with 50 columns. It has two rows inserted. I want to add 3rd row by taking values from that table only.



insert into Sample([IDX],[CODE]
,[NAME]
,[LABEL]
,[BILLING_ADDRESS]
,[PRIMARY_CONTACT_NAME]
,[PRIMARY_CONTACT_EMAIL]
,[SECONDARY_CONTACT_NAME]
,[SECONDARY_CONTATCT_EMAIL]
,[RDBMS_SERVER]
,[RDBMS_DB_NAME]
,[RDBMS_LOGIN]
,[RDBMS_PWD]
,[ETL_FOLDER_PATH])
values (select [IDX],[CODE]
,[NAME]
,[LABEL]
,[BILLING_ADDRESS]
,[PRIMARY_CONTACT_NAME]
,[PRIMARY_CONTACT_EMAIL]
,[SECONDARY_CONTACT_NAME]
,[SECONDARY_CONTATCT_EMAIL]
,[RDBMS_SERVER]
,[RDBMS_DB_NAME]
,[RDBMS_LOGIN]
,[RDBMS_PWD]
,[ETL_FOLDER_PATH]
from Sample where IDX = 2
)


In the above example i taken only few columns.
While trying to execute this query it is showing message as follows.




There are more columns in the INSERT statement than values specified
in the VALUES clause. The number of values in the VALUES clause must
match the number of columns specified in the INSERT statement.




How to solve it?



Thanks





No comments:

Post a Comment