You need to add a linked server in your current sql server if the 2nd database lies on sql database server other than the server on which your 1st database...
if your table1(inwhich you want to insert the data) has col1(identity col),col2,col3 and table2 has col1(identity col),col2,col3 then the script should be