Skip to content

DBAzine.com

Sections
Personal tools
You are here: Home » SQL Server » SQL Server Articles Archive » Implementing Identity Columns in SQL Server » How do I handle situations like this?
Seeking new owner for this high-traffic DBAzine.com site.
Tap into the potential of this DBA community to expand your business! Interested? Contact us today.
Who Are You?
I am a:
Mainframe True Believer
Distributed Fast-tracker

[ Results | Polls ]
Votes : 3568
 

Comment

Above in this comment thread: Implementing Identity Columns in SQL Server

How do I handle situations like this?

Posted by CHID at 2005-12-22 07:25 AM
INSERT INTO products (SalesID, SKU) VALUES(4, '01216326').

instead i am bound to insert like this...

Insert into productsduplicate SELECT * FROM products.
it is asking me to specify column list..

I shall be glad if you can let me know if there is any way that i can achieve that without specifying column list

or is that the way i am bound to specify columns also.

i use SQLSERVER2000

With Regards,
chid

Best Practices

Posted by mougue at 2006-02-14 09:38 PM
Hi,
The best practice is to always specify a column list when you can. If you can't or for some reason to design a solution where you won't know the composition of the columns, you can use a SELECT INTO statement in order to create a table which has the results of your select statement. This usually means that there cannot be an existing table with a differet sent of data and that the table created by the SELECT INTO will be the only one that can exist with the specified set of data, unless you run subsequent insert statements.

Hope this helps.
 
Transaction Management
Reduce downtime and increase repeat sales by improving end-user experience.
Free White Paper
Database Recovery
Feeling the increased demands on data protection and storage requirements?
Download Free Report!
 
 

Powered by Plone