Sandya
Sandya

Reputation: 5

What's the meaning of this simple SQL statement?

I am new to T-SQL. What is the meaning of the following statement?

BEGIN 
    UPDATE table_name 
    SET a = ISNULL(@f_flag,0) 
END

Upvotes: 0

Views: 40

Answers (1)

SteveD
SteveD

Reputation: 867

  • Begin, End: The Begin and End is not needed. It identifies a code block, usefull if more that one statement.
  • UPDATE table_name: Update the data in the table "table_name".
  • SET: Keyword, start the comma delimited list of column - value pairs to update
  • a = : a is the column mame, to value to the right of the = is what value will be used
  • ISNULL(@f_flag,0): The value to assign. In this case the IsNull checks the value of the @f_flag variable, and if it is null, then use a 0.

*Note: that there is no "WHERE" clause here, therefore, all rows in the table will be updated.

Upvotes: 3

Related Questions