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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 RESOLVED: Copy from one table to another

Author  Topic 

kpgraci
Yak Posting Veteran

68 Posts

Posted - 2012-05-22 : 11:33:58
I have a source table that looks like this:

DefaultCoverage
LOB INT
Coverage VarChar
Scope INT

Destination Table:

PolicyCoverage
SN Varchar
PID INT
Coverage VarChar
Limit VarChar
Premium MONEY
Scope INT

The query is:

INSERT INTO PolicyCoverage SN, PID, Coverage, Scope SELECT 'LA2007' AS SN, 29 AS PID, Coverage, Scope FROM DefaultCoverages WHERE LOB=7

I get a systax error near SN

What am I doing wrong?

kpg

kpgraci
Yak Posting Veteran

68 Posts

Posted - 2012-05-22 : 11:39:18
I figured it out, need to add parens else it thinks that SN is a aliais for the table.

INSERT INTO PolicyCoverage (SN, PID, Coverage, Scope) SELECT 'LA2007' AS SN, 29 AS PID, Coverage, Scope FROM DefaultCoverages WHERE LOB=7



kpg
Go to Top of Page
   

- Advertisement -