当前位置:首页 » 编程语言 » 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;

热点内容
安卓如何连接倍思 发布:2025-09-08 15:14:14 浏览:551
天刀起号脚本 发布:2025-09-08 15:08:47 浏览:596
存储过程日期参数 发布:2025-09-08 14:33:46 浏览:831
核桃编程库 发布:2025-09-08 14:25:30 浏览:120
明日之后怎么同服务器 发布:2025-09-08 14:05:50 浏览:80
安卓手机怎么定位置 发布:2025-09-08 13:45:01 浏览:386
如何找到服务器数据 发布:2025-09-08 13:37:05 浏览:633
编程值得学吗 发布:2025-09-08 13:35:44 浏览:870
db2数据库控制中心 发布:2025-09-08 13:29:18 浏览:906
半导体存储芯片的驿码驱动方式 发布:2025-09-08 12:43:06 浏览:629