已知:USER表里ID为主键,列NAME为varchar型,如何将查询【SELECT NAME FROM USER WHERE ID = '12'】的结果赋值给变量@NAME?
3 个解决方案
#1
DECLARE @NAME VARCHAR(40)
SELECT @NAME=NAME FROM USER WHERE ID = '12'
SELECT @NAME=NAME FROM USER WHERE ID = '12'
#2
存储过程里,如何将查询结果赋值给一个变量?
已知:USER表里ID为主键,列NAME为varchar型,如何将查询【SELECT NAME FROM USER WHERE ID = '12'】的结果赋值给变量@NAME?
declare @NAME as varchar(10)
SELECT @NAME = NAME FROM USER WHERE ID = '12'
已知:USER表里ID为主键,列NAME为varchar型,如何将查询【SELECT NAME FROM USER WHERE ID = '12'】的结果赋值给变量@NAME?
declare @NAME as varchar(10)
SELECT @NAME = NAME FROM USER WHERE ID = '12'
#3
thank you
#1
DECLARE @NAME VARCHAR(40)
SELECT @NAME=NAME FROM USER WHERE ID = '12'
SELECT @NAME=NAME FROM USER WHERE ID = '12'
#2
存储过程里,如何将查询结果赋值给一个变量?
已知:USER表里ID为主键,列NAME为varchar型,如何将查询【SELECT NAME FROM USER WHERE ID = '12'】的结果赋值给变量@NAME?
declare @NAME as varchar(10)
SELECT @NAME = NAME FROM USER WHERE ID = '12'
已知:USER表里ID为主键,列NAME为varchar型,如何将查询【SELECT NAME FROM USER WHERE ID = '12'】的结果赋值给变量@NAME?
declare @NAME as varchar(10)
SELECT @NAME = NAME FROM USER WHERE ID = '12'
#3
thank you