SQL Server 局部变量的使用
2022-11-12 09:53:00
内容摘要
这篇文章主要为大家详细介绍了SQL Server 局部变量的使用,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!A. 使用 DECLARE下例使用名为 @f
文章正文
这篇文章主要为大家详细介绍了SQL Server 局部变量的使用,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!
A. 使用 DECLARE下例使用名为 @find 的局部变量检索所有姓以 Ring 开头的作者信息。代码如下:
1 2 3 4 5 6 7 8 | <code> Use pubs declare @find varchar(30) set @find= 'Ring%' select au_lname,au_fname,phone from authors where au_lname like @find </code> |
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <code> USE pubs SET NOCOUNT ON GO DECLARE @pub_id char(4), @hire_date datetime SET @pub_id = '0877' SET @hire_date = '1/01/93' -- Here is the SELECT statement syntax to assign values to two local -- variables. -- SELECT @pub_id = '0877' , @hire_date = '1/01/93' SET NOCOUNT OFF SELECT fname, lname FROM employee WHERE pub_id = @pub_id and hire_date >= @hire_date </code> |
注:关于SQL Server 局部变量的使用的内容就先介绍到这里,更多相关文章的可以留意
代码注释