今天寫乙個小儲存過程,呵呵!功能大家試一下就知道了。
create proc proc_test
@uid int=0 output,
@uname nvarchar(50)=null output
asbegin
declare dd cursor scroll for
select uid,uname from steven
open dd
fetch first from dd into @uid,@uname
while (@@fetch_status = 0)
begin
--列印所有迴圈的值
--print @uid
--print @uname
update brain set username=@uname where uid=@uid
fetch next from dd into @uid,@uname
endclose dd
deallocate dd
end
用乙個表的記錄更新另外乙個表
用table 1的address,phone number更新table 2的address,phone number,注意 1.set 後面加上要更新的列,有多個要更新的列時,加上多個列,2.where 後面加上table 1和table 2的關聯列,有多個關聯列時,加上多個列 3.rownum用...
根據乙個表的字段,更新另外乙個表的字段
update table a set latesttm u.tm,latestdata u.data from select from table b inner join select max tm newesttm from table b group by stcd v on drp.tm v...
SQL用另外乙個表的資料更新本表資料
update s set s.classbid lc.itemid from dbo.lv servers as s inner join dbo.lv linechannel as lc on s.classsid lc.classid where s.classbid 0 sql用另外乙個表的資...