简体   繁体   中英

Inserting items from one table into another

Using the code below in an effort to take stuff from "tablename" to "result". This results in an error shown below. When i double click on the comma in the error, it has a red line below the comma in the second line between acct and run and then the right parenthese on the second line. First, does this tell me that the entire second line is flawed?

Msg 102, Level 15, State 1, Line 2

Incorrect syntax near ','.

Insert into dbo.result(account,unit,name1,name2,address1,address2,city,st,zip,zipext,addressty,latitude,longitude,telephone,employment,ownership,naicscode,pluscode)
   Select (acct,run,legalname,busname,pladdr1,pladdr2,plcity,plstate,plzip,plzipx,moaddtype,latitude,longitude,phonenum,employment,own,naics,plus)
   From dbo.tablename

Skip the extra parentheses:

Insert into dbo.result(account, unit, name1, name2, address1, address2, city,
       st, zip, zipext,addressty, latitude, longitude,
       telephone, employment, ownership, naicscode, pluscode)
   Select acct, run, legalname, busname, pladdr1, pladdr2, plcity,
          plstate, plzip, plzipx, moaddtype, latitude, longitude,
          phonenum, employment, own, naics, plus
   From dbo.tablename

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM