SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Create backup table not working. Please help!
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sccrsurfer
Starting Member

USA
43 Posts

Posted - 02/07/2013 :  10:43:57  Show Profile  Reply with Quote
Hi Guys, I've tried two different approaches to creating a backup table. The end result I want is an exact duplicate the sample name below "existing_table."

Using SQL 2005 btw with 2008 management studio.

When I try:

CREATE TABLE [dbName].[dbo].[backup]
AS SELECT * FROM [dbName].[dbo].[existing_table]

I get a syntax error saying this: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'AS'.


Then I tried this:

SELECT *
INTO [TMCCommon].[dbo].[backup]
FROM [TMCCommon].[dbo].[existing_table]

It said that all of the rows were affected, but the new table I want created "backup" is nowhere to be found! And it says when I try to run the query again that the "backup" object already exists.

Any clue on what's going on?

Thanks!

mandm
Yak Posting Veteran

72 Posts

Posted - 02/07/2013 :  10:47:52  Show Profile  Reply with Quote
Management Studio has a bit of quirk where it won't show a new object until you refresh. Go to the tables in the left nav then right click and choose refresh. Your table should now appear.
Go to Top of Page

sccrsurfer
Starting Member

USA
43 Posts

Posted - 02/08/2013 :  09:33:41  Show Profile  Reply with Quote
Boy do I feel sheepish. That was it! Thanks.
Go to Top of Page

mandm
Yak Posting Veteran

72 Posts

Posted - 02/08/2013 :  11:02:15  Show Profile  Reply with Quote
You're welcome.

No need to feel sheepish. It fooled me once too.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000