sql-Defining variables

Source: Internet
Author: User

Declare @subject nvarchar Set @subject = (select subject from dbo. Scores where id=1)

  

--select @subject =subject from dbo. Scores where id=1--a scalar scalar is a single value, and if it is a result set, the final value of the set is the last value in the result set, select @subject Set the self-increment
INSERT INTO dbo. Student values (' Harry ', ' Male ', ' Max '); select @ @IDENTITY;   INSERT INTO dbo. Student output inserted.id values (' Li Liu ', ' Male ', 41)

  

Execution of certain scripts requires consideration of the behavior of the judgment loop, so there is an if and other struct if () {}------------>sqlserver is the IF () Begin end
    declare @name nvarchar (50) = ' Harry '  if (@name = ' Harry ')  begin    Select ' True '  end  else  begin  Select ' False '  

  

Cycle-Calculates the 1-100 and
  declare @int int=1;  declare @total int=0;  while (@int <=100)  begin  set @[email protected][email protected];  Set @[email protected] +1;  End  Select @total

  

sql-Defining variables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.