當前位置:首頁 » 操作系統 » 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

熱點內容
php描述 發布:2025-09-13 22:09:25 瀏覽:205
sql2000死鎖 發布:2025-09-13 21:57:48 瀏覽:765
F7編譯 發布:2025-09-13 21:55:53 瀏覽:591
怎樣使用sql 發布:2025-09-13 21:55:51 瀏覽:187
墨跡天氣怎麼取消隱藏的伺服器 發布:2025-09-13 21:36:28 瀏覽:36
sql資料庫入門到精通 發布:2025-09-13 20:13:50 瀏覽:739
微信設密碼鎖在哪裡設華為手機 發布:2025-09-13 20:04:03 瀏覽:144
電腦代理伺服器怎麼看 發布:2025-09-13 19:40:52 瀏覽:924
c語言架構 發布:2025-09-13 19:26:26 瀏覽:834
app框架源碼 發布:2025-09-13 19:17:56 瀏覽:929