临时变量声明和赋值 [英] Temporary variable declaration and assignment
本文介绍了临时变量声明和赋值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在sql查询中声明和分配temporay变量.是否有任何工具或技巧来做到这一点?
how to declare and assign temporay variable in sql query.Is there any facility or trick to do this?
推荐答案
尝试:
DECLARE @VarName AS VARCHAR(20)
SET @VarName = 'Hello'
declare @id int
set @id=100
Select * from emp where id=@id
这将从emp表返回ID为100的记录
This will return records from emp table having id of 100
DECLARE @Variable VARCHAR(20)=``Testing''
SELECT @Variable
DECLARE @Variable VARCHAR(20) = ''Testing''
SELECT @Variable
这篇关于临时变量声明和赋值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文