Click here to Skip to main content
14,635,212 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have this query that I'm having some issues with. I'm using 2 MS SQL Server 12. I'm new to SQL. I'm trying to run a query to extract that data from the one server and bring it into another MS SQL Server 12 which hosts the tables that will populate a web page. I'm also using Microsoft using SQL Server Management Studio (SSMS). This is the error that I'm getting "Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'INTO'." When I double click on the errro message it takes me to the line "INTO [dbo].[VISION_SALEHIST2]". I'm guessing something is wrong with the syntax of the coding.
The origin data is located in a view table instead of a table.
Any help would be greatly appreciated.  The origin data is located in a view table instead of a table.

The query is below.

DROP TABLE [dbo].[VISION_SALEHIST2]
SELECT 

  MNC,
  PID,
  LINE_NUM,
  CURRTENT_OWNER,
  FUTURE,
  mad_own_id,
  BOOK_PG,
  CONVERT(datetime, SALE_DATE) AS SALE_DATE,
  SALESPRICE,
  CERTIFICATE,
  INSTRUMENT,
  QUALIFIED,
  OWN_NAME,
  CO_OWN_NAME,
  ADDRESS1,
  ADDRESS2,
  CITY,
  STATE,
  ZIP,
  
INTO [dbo].[VISION_SALEHIST2]
 
  FROM [TOMSQLVISION].[VISION_2020].[REAL_PROP].[VW_HSALE]

What I have tried:

I've tried to put a ; after the DROP TABLE [dbo].[VISION_SALEHIST2], I removed the .dbo then added it back, added an * afer select then removed it.  Rearranged the >DROP TABLE [dbo].[VISION_SALEHIST2], SELECT, INTO [dbo].[VISION_SALEHIST2],FROM [TOMSQLVISION].[VISION_2020].[REAL_PROP].[VW_HSALE] statements
Posted
Updated 3-Aug-20 3:57am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

The only thing obvious I see is
ZIP,
(the trailing comma)

You could also fully qualify
[dbo].[VISION_SALEHIST2]
ie
[SomeDatabase].[dbo].[VISION_SALEHIST2]
in both occurences
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100