sql server - T-SQL: What does "SELECT 1 BEGIN TRANSACTION" mean? -


i got t-sql code error handling:

if @@trancount = 0 begin     insert #tmperrors (error)     select 1     begin transaction end 

i know inserts 1 #tmperrors table flag error has occurred. couldn't understand following sentence:

select 1 begin transaction 

i thought begin transaction executable statement itself, seems pseudo clause. have explanation?

thanks!

in sql server, select statement not require from clause.

select 1 complete statement itself, though in case used in conjunction insert into.

begin transaction separate statement.

basically statement saying "if there no current transaction, log that, , create transaction."

if @@trancount = 0 -- if no current transaction begin      -- insert "1" #tmperrors     insert #tmperrors (error)     select 1      -- begin transaction     begin transaction end 

Comments