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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Insert into an existing table?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

taunt
Posting Yak Master

116 Posts

Posted - 06/11/2013 :  13:33:36  Show Profile  Reply with Quote
Hello I'm having issues inserting data in an existing table. I do this:

SELECT *
into itemsNRSH
FROM items
WHERE (ReleaseDate = '06/11/2013') AND (StockQty > 0)

That will create a table with the data I want, but if the table is already there it won't. What do I need to try? When I tried:

into into itemsNRSH
SELECT *
FROM items
WHERE (ReleaseDate = '06/11/2013') AND (StockQty > 0)

It says no column list was used. So what am I doing wrong?

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1054 Posts

Posted - 06/11/2013 :  13:38:45  Show Profile  Reply with Quote
quote:
Originally posted by taunt

Hello I'm having issues inserting data in an existing table. I do this:

SELECT *
into itemsNRSH
FROM items
WHERE (ReleaseDate = '06/11/2013') AND (StockQty > 0)

That will create a table with the data I want, but if the table is already there it won't. What do I need to try? When I tried:

into into itemsNRSH
SELECT *
FROM items
WHERE (ReleaseDate = '06/11/2013') AND (StockQty > 0)

It says no column list was used. So what am I doing wrong?



Are you sure this was the error? Can you copy/paste the exact error thrown by the SQL server?

Cheers
MIK
Go to Top of Page

djj55
Constraint Violating Yak Guru

USA
337 Posts

Posted - 06/11/2013 :  15:04:37  Show Profile  Reply with Quote
You are correct the select * into will create the table and I assume you ment INSERT INTO itemsNRSH select *?

Are you executing the second query after the first?

djj
Go to Top of Page

taunt
Posting Yak Master

116 Posts

Posted - 06/11/2013 :  17:17:23  Show Profile  Reply with Quote
Yep it was annoyed that I didn't have the columns mapped. I re did it with the columns in itemsNRSH and items, and it worked.
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.11 seconds. Powered By: Snitz Forums 2000