變數使用@
宣告:DECLARE + @Name +型態
賦值:SET @Name = ' ';
ex:
DECLARE @test INT;
SET @test = 123;
綜合為 DECLARE @test INT = 123;
也可以用Select 取值
ex:
DECLARE @test INT = 0;
SELECT @test = 某表格.欄位 From 表格
=============================我是分隔線============================
字串宣告
DECLARE @Test VARCHAR(20) = 'Hello world';
DECLARE @Test2 VARCHAR(20) = '';
SET @Test2 = SUBSTRING(@Test,1,5);
則結果為: @Test2 = Hello