yes. you can use transaction to handle this situation.
some commands are there

BEGIN TRANSACTION
<sql code>
COMMIT / ROLLBACK TRANSACTION

for more use the msdn help....