SQLTeam.com | Weblogs | Forums

How to insert data in identity column

sql2008r2

#1

i have 2 database both are same .
i want to insert one database table to another database table .
if there are identical column .
i m using script like
insert into [tablename]

select * from [databasename].dbo.tablename


#2

Do not use the *. List the columns for both the insert and the select. If there is a identity column you will need to turn on identity insert.


#3

any other way to insert in identy column. including * use


#4

lookup SET IDENTITY_INSERT


#5

i have used but not working when using * in query


#6

No, you cannot use IDENTITY_INSERT ON and * at the same time, it is just not allowed.


#7

To save you typing all the column names you can query the database to get that list instead. Or you can just DRAG the table name into your code (in SSMS)