• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

SQL SERVER 2005 Insert question

In SQL Server 2005 are you allowed to do a Select * in an INSERT statement ie:
INSERT INTO TABLE1
SELECT * FROM TABLE2
0
ciara_barry123
Asked:
ciara_barry123
  • 3
2 Solutions
 
hongjunCommented:
yes it's allowed.
0
 
hongjunCommented:
Yes provided the number of columns and the columns in table1 and table2 are the same.
0
 
hongjunCommented:
If the order is different, I would suggest you list out the columns

insert into table1 (col1, col2)
select col1, col2 from table2
0
 
Miriam0000Commented:
If there are ID fields involved, you will also need to specify all of the other columns and let the ids just generate
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now