How to insert data in identity column

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

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.

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


i have used but not working when using * in query

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

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)