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