当前位置:首页 » 操作系统 » set数据库

set数据库

发布时间: 2023-06-12 22:31:31

sql 语句里set是什么意思啊

SET是SQL Server 中对已经定义的变量赋值的方式,经常与update语句一起使用。

语法:UPDATE表名称SET列名称=新值WHERE列名称=某值

例子如下:

update A set name=小张 where name =张三 //将小张的姓名改为张三

update A set name=小王 where name =王五 //将小王的姓名改为王五

参考资料:网络-update

⑵ 在sql2005数据库执行存储过程出现:关键字 'SET' 附近有语法错误。 怎么处理呀代码如下

换成

CREATE proc [dbo].[GetDataSet]
@TableList Varchar(1024)='*',--搜索表的字段,比如:’id,datatime,job‘,用逗号隔开
@TableName Varchar(100), --搜索的表名
@SelectWhere Varchar(1024)='',--搜索条件,这里不用写where,比如:job=’teacher‘and class='2'
@SelectOrderId Varchar(50),--表主键字段名。比如:id
@SelectOrder Varchar(200)='', --排序,可以使用多字段排序但主键字段必需在最前面.也可以不写,比如:order by class asc
@intPageNo int=1, --页号
@intPageSize int=10 ,--每页显示数
@RecordCount int OUTPUT --总记录数(存储过程输出参数)
as
declare @TmpSelect NVarchar(4000)
declare @Tmp NVarchar(4000)
declare @pagecount int
set nocount on--关闭计数
set @RecordCount=0
set @TmpSelect = 'select @RecordCount=count(*) from '+@TableName+' where '+@SelectWhere
execute sp_executesql
@TmpSelect, --执行上面的sql语句
N'@RecordCount int OUTPUT' , --执行输出数据的sql语句,output出总记录数
@RecordCount OUTPUT
if (@RecordCount = 0) --如果没有贴子,则返回零
return 0
set @pagecount = @RecordCount/@intPageSize
if(@RecordCount%@intPageSize>0)
set @pagecount=@pagecount+1
if(@pagecount<=0)
set @pagecount=1
if(@intPageNo>@pagecount)
set @intPageNo=@pagecount
/*判断页数是否正确*/
--if (@intPageNo - 1) * @intPageSize > @RecordCount --页号大于总页数,返回错误
--set @intPageNo=@pagecount
set nocount off--打开计数
if @SelectWhere != ''
begin
set @TmpSelect = 'select top '+str(@intPageSize)+' '+@TableList+' from '+@TableName+' where '+@SelectOrderId+' not in(select top '+str((@intPageNo-1)*@intPageSize)+' '+@SelectOrderId+' from '+@TableName+' where '+@SelectWhere +' '+@SelectOrder+') and '+@SelectWhere +' '+@SelectOrder
end
else
begin
set @TmpSelect = 'select top '+str(@intPageSize)+' '+@TableList+' from '+@TableName+' where '+@SelectOrderId+' not in(select top '+str((@intPageNo-1)*@intPageSize)+' '+@SelectOrderId+' from '+@TableName+''+@SelectOrder+') '+@SelectOrder
end
execute sp_executesql @TmpSelect
return(@@rowcount)
GO

热点内容
什么是永恒流量密码 发布:2025-07-11 15:31:08 浏览:767
离线存储器 发布:2025-07-11 15:29:22 浏览:662
asynctask上传 发布:2025-07-11 15:20:17 浏览:590
编程语言的图标 发布:2025-07-11 15:18:04 浏览:417
分式编译器 发布:2025-07-11 15:15:05 浏览:71
烤生蚝的调料怎么配置 发布:2025-07-11 15:15:02 浏览:550
优酷视频上传分辨率 发布:2025-07-11 15:15:00 浏览:603
超时代加密提取工具 发布:2025-07-11 15:13:37 浏览:962
重庆金税盘接入服务器连接地址 发布:2025-07-11 15:02:10 浏览:356
手机阴阳师脚本辅助 发布:2025-07-11 14:43:13 浏览:17