当前位置:首页 » 操作系统 » 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-04-05 13:20:10 浏览:419
Hp关闭ftp功能 发布:2025-04-05 13:20:08 浏览:578
php苗木 发布:2025-04-05 13:19:58 浏览:289
u盘当加密狗 发布:2025-04-05 12:57:25 浏览:765
sql语言培训机构 发布:2025-04-05 12:57:23 浏览:998
360网盘上传限制 发布:2025-04-05 12:55:52 浏览:579
什么安卓平板电脑打王者最好 发布:2025-04-05 12:55:51 浏览:818
androidstudio闪退 发布:2025-04-05 12:35:54 浏览:901
腾讯视频青少年模式原始密码是多少 发布:2025-04-05 12:27:21 浏览:540
企业文档存储管理系统 发布:2025-04-05 12:21:20 浏览:751