SQL Query Syntax Error Msg 102 Level 15 State 1 Line 1

I’m trying to copy a table from one database to another and using the following SQL query:
SELECT * INTO dbo.TOG$Sales Cr_Memo Header FROM dbo.TEST TEST TEST TEST TEST$Sales Cr_Memo Header

Resulting with error: Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ‘Cr_Memo’.

I’m new to this arena and would appreciate any help/direction. BTW…running SQL Server 2005 and using the SQL Server Management Studio to do this.
Thank you!

If it was purely MS SQL server forum, the answer would be simple - as your table name contains spaces, you must include it in square brackets.

Question is - WHY you are doing this in Navision database by means of TSQL script?

You should know, that first rule is NEVER manipulate Navision SQL database directly!
The ONLY allowed keyword is SELECT (for reporting purposes), never use INSERT / UPDATE / DELETE.

Thank you for the updated information. Question: Is there a more efficient and secure way of accomplishing the copying of one table to another between the 2 databases? Through the NAV Client? I was just researching this and came across a forum in SQL; that’s how I ended up with this query statement.

Thank you…

Yes, it MUST be done through NAV Client.

Tables created directly are “invisble” for Navision - you would not see them neither in Object Designer, nor the application itself will be able to use such table, that’s first thing to say.
Besides, Navision Table object contains much more, than field structure - as you should know, it can contain even C/AL code, besides other things. This part can not be created and maintained otherwise, as through Object Designer in NAV client.

The correct way is exporting / importing Table Object from within NAV client, and data are transfered by Navision means, too.

Be aware , that simple and straightforward copying from one DB to another one table data is possible in very rare cases with some simple supplemental tables. In Credit Memo Header does NOT belong to this group - too much linked tables are involved, which after such straightforward CMH table data copying will be out of sync and you’ll end up with corrupt database.

I can not give you precise instructions what to do in your exact case, as I do not know full info, plus, it goes beyond the amount that can be squeezed into one single forum post.

My advice is - look for someone in your team who can mentor you, as your initial question proves that obviously you do not yet have the necessary knowledge of NAV data structures and maintenace principles.
Please, do not take it personal, I only want to keep you from doing things that might be later impossible to correct… We all started the same way, nobody has born with full knowledge of everything…