当前位置:首页 » 编程语言 » sqlserver通配符

sqlserver通配符

发布时间: 2025-09-08 10:41:59

sql中,LIKE 的 用法

SQL Server里有[^]。
楼主要的查询是
select * from A where 姓名字段 not like '[^王]%'

是就是非的非。

Ⅱ sqlserver怎么创建存储过程

SQL创建存储过程的基础语法是:

create proc | procere pro_name

[{@参数数据类型}=[默认值][output], {@参数数据类型}=[默认值][output], .... ]

as

SQL_statements

常见的创建存储过程实例如下:

1、创建不带参数的存储过程:

create proc proc_get_student

as

select*from student;

执行存储过程:

exec proc_get_student;

2、带参数的存储过程:

create proc proc_find_stu(@startId int, @endId int)

as

select*from student where id between @startId and @endId;

执行存储过程:

exec proc_find_stu 2, 4;

3、带通配符参数的存储过程:

create proc proc_findStudentByName(@name varchar(20)='%j%', @nextName varchar(20)='%')

as

select*from student where name like @name and name like @nextName;

执行存储过程:

exec proc_findStudentByName;

exec proc_findStudentByName '%o%', 't%';

4、带输出参数的存储过程:

create proc proc_getStudentRecord( @id int, -- 默认输入参数

@name varchar(20) out, -- 输出参数

@age varchar(20) output -- 输入输出参数 )

as

select @name = name, @age = age from student where id = @id and sex = @age;

执行存储过程:

declare @id int, @name varchar(20), @temp varchar(20);

set @id = 7;

set @temp = 1;

exec proc_getStudentRecord @id, @name out, @temp output;

select @name, @temp;

print @name + '#' + @temp;

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:585
制作脚本网站 发布:2025-10-20 08:17:34 浏览:880
python中的init方法 发布:2025-10-20 08:17:33 浏览:574
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:761
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:676
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:1004
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:248
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:108
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:798
python股票数据获取 发布:2025-10-20 07:39:44 浏览:705