/*
Sql server 存储过程中怎么将变量赋值
*/
--SQL赋值语句
DECLARE @test1 INT
SELECT @test1 = 111
SET @test1 = 222
--SQL函数赋值,假定count()是自定义函数
DECLARE @test2 INT
SELECT @test2 = COUNT(*) FROM sys.sysobjects
--SQL存储过程赋值,直接传参处理(类似C语言中的指针吗)
IF OBJECT_ID('sp_test') IS NOT NULL DROP PROCEDURE sp_test
GO
CREATE PROCEDURE sp_test(@test INT OUTPUT)
AS
BEGIN
SELECT @test = 999
END
GO
DECLARE @test3 INT
EXEC sp_test @test3 OUTPUT
SELECT @test3
DROP PROCEDURE sp_test
GO