can we insert into two tables with single sql statement?
No you can't.
If you want to ensure the atomicity of an operation that requires data to be inserted into 2 tables, you should protect it in a transaction. You either use the SQL statements BEGIN TRAN
and COMMIT TRAN
, or you use a transaction boundary in whatever language you're using to develop the db access layer. E.g. something like Connection.StartTransaction
and Connection.Commit
(or Connection.Rollback
on an error).