表变量使用
上一篇 /
下一篇 2012-04-10 15:36:54
/ 个人分类:数据库
begin
--利用表变量@table,将table1中的url更新成W+自增数字组成的字符串
declare @table table(PID UniqueIdentifier,ID int)
declare @count int
insert into @table select pid,row_number() over(order by PID) from TABLE1
select @count=count(pid) from TABLE1
declare @tempPID UniqueIdentifier
declare @tempID int
set @tempID=1
while(@tempID<@count+1)
begin
select @tempPID=PID from @table where ID=@tempID
update TABLE1 set url='W'+cast(@tempID as nvarchar(600)) where pid=@tempPID
set @tempID=@tempID+1
end
end
--记录
工作中的问题,这是个本办法,我承认……哈哈
收藏
举报
TAG:
表变量