什么是错误....? [英] what is the error....?

查看:107
本文介绍了什么是错误....?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

declare @code varchar(50)
declare @new varchar(50)

declare udates cursor for 

SELECT DISTINCT E.C_EmpCode,replace(e.C_EmpCode,'0','100') FROM Tbl_Emp_Mst E
JOIN Tbl_User_Info U ON U.C_Code=E.C_EmpCode
JOIN Tbl_UserRights US ON US.c_userid=E.C_EmpCode
JOIN Tbl_FS_Mst FS ON FS.C_EmpNo=FS.C_EmpNo
JOIN tbl_fs_emp_rel FSM ON FSM.c_emp_code=E.C_EmpCode
JOIN FSHEIRARCHY FSH ON FSH.empcode=E.C_EmpCode

open updates
fetch next from updates into @code,@new
while @@FETCH_STATUS=0
begin
update Tbl_Emp_Mst set C_EmpCode=@new where C_EmpCode=@code
--update Tbl_FS_Mst set C_EmpNo=@new where C_EmpNo=@code
update tbl_fs_emp_rel set c_emp_code=@new where c_emp_code=@code
update fsheirarchy set empcode=@new where EmpCode=@code

update Tbl_User_Info set C_Code=@new where C_Code=@code
update Tbl_User_Info set C_UserID=@new where C_UserID=@code
update Tbl_User_Info set C_Password=@new where C_Password=@code

update Tbl_UserRights set c_userid=@new where c_userid=@code

fetch next from updates into @code,@new
end
close updates
deallocate updates



执行脚本时出错。


error while executing script.

Msg 16916, Level 16, State 1, Line 6
A cursor with the name 'updates' does not exist.
Msg 16916, Level 16, State 1, Line 14
A cursor with the name 'updates' does not exist.
Msg 16916, Level 16, State 1, Line 30
A cursor with the name 'updates' does not exist.
Msg 16916, Level 16, State 1, Line 31
A cursor with the name 'updates' does not exist.

推荐答案

出现错误:

There's the error:
declare udates cursor for
declare updates cursor for


您已将Cursor名称声明为 udates 但在你的游标中你已经已使用更新



使用 CURSOR <$ S中的c $ c> Bad Practice QL服务器。它导致性能问题



请参考。



http ://stackoverflow.com/questions/58141/why-is-it-considered-bad-practice-to-use-cursors-in-sql-server [ ^ ] br />


SQL Server DO和DONT [ ^ ]



替代 CURSOR



http://www.dotnet-tricks .COM /教程/ SQLSERVER / IT5G180512-S QL-Server-Cursor-Alternatives.html [ ^ ]
You have declared Cursor name as udates but with in your CURSOR you have used updates

Using CURSOR is Bad Practice in SQL Server .It causes Performance Issues .

Please Refer it.

http://stackoverflow.com/questions/58141/why-is-it-considered-bad-practice-to-use-cursors-in-sql-server[^]

SQL Server DO's and DONT's[^]

Alternate for CURSOR

http://www.dotnet-tricks.com/Tutorial/sqlserver/IT5G180512-SQL-Server-Cursor-Alternatives.html[^]


这篇关于什么是错误....?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆