pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

運行舊版本存儲過程的 SQL Server

SQL Server running old versions of stored procedures(運行舊版本存儲過程的 SQL Server)
本文介紹了運行舊版本存儲過程的 SQL Server的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我們有 1 個用戶,當他們從 VB 應用程序運行存儲過程時,它運行的是舊版本的 SP.舊版本是指被存儲過程更新覆蓋的版本.

We have 1 user that when they run a stored procedure from a VB application, it runs an old version of the SP. By old version, I mean the version that was overwritten by updates to the stored procedure.

  • 我們只有 1 個架構 (dbo)
  • 我在服務器上的任何其他數據庫(包括主數據庫)中檢查了相同的 SP,它只存在一次
  • 我們確實使用 NT Auth
  • 我使用 SQL Profiler 來確保調用了正確的 SP.
  • 我什至通過在 BEGIN 之后對第一行的 sp 進行以下更改來對此進行測試:

  • We only have 1 schema (dbo)
  • I checked for the same SP in any other database (including master) on the server and it only exists once
  • We do use NT Auth
  • I used SQL Profiler to make sure the right SP was being called and it was.
  • I even tested this by making the following change to the sp on the first line after BEGIN:

raiserror('這是更新后的 SP 有錯誤!',16,1)

raiserror('This is the updated SP with an error!',16,1)

返回

該用戶不會收到此錯誤,而是收到原始錯誤.他們得到的錯誤并不重要,因為它已被修復,但就像這 1 個用戶正在調用不同的 SP.

This user does not get this error, they instead get the original error. The error they get is not important because it has been fixed but it is like this 1 user is calling a different SP.

更令人困惑的是,幾個月前我們遇到了同樣的問題,使用不同的數據庫和 vb 應用程序以及 2 個不同的用戶.我們為解決他們的問題所做的是將它們從 Active Director 中刪除,然后使用不同的名稱添加它們.

To makes thing more confusing, we had the same issue a few months ago with a different database and vb app and 2 different users. What we did to fix their issue is remove them from active director and then add them with a different name.

有沒有人知道可能會發生什么,我可以嘗試其他方法而不是重新創建用戶,或者有沒有其他人遇到過這個問題?請告訴我我沒有瘋.

Does anyone have any idea of what might be happening, something else I could try instead of recreating the user, or has anyone else ever ran across this? Please tell me I am not insane.

EDIT:我們在 VB 應用程序和 SQL Server 中更改了 SP 的名稱并觀察 SQL Profiler,它確實運行重命名的 SP,但它仍然運行在SP.所有代碼都被刪除了,唯一存在的是 Raiserror ......肯定有我們遺漏的東西.

EDIT: We changed the name of the SP in both the VB app and in SQL Server and watching SQL Profiler, it does run the renamed SP but it still runs the old code that was in the SP. All code has been removed and the only thing that exists is the Raiserror... There has to be something we are missing.

EDIT2:似乎添加到 SP 的可選 BIT 參數與此有關.以下是幾個月前更改前 SP 的樣子:

EDIT2: Would appear that an optional BIT paramater added to the SP has something to do with this. Here is what the SP looked like a few months ago before a change:

ALTER PROCEDURE [dbo].[BulkLoadSomeData]
    @UserName varchar(50),
    @FileName as varchar(max),
    @OriginalFileName as varchar(max)
AS
BEGIN
  SET NOCOUNT ON;
  BULK INSERT ....
  ...Process the data...
END

現在:

ALTER PROCEDURE [dbo].[BulkLoadSomeData]
  @UserName varchar(50),
  @FileName as varchar(max),
  @OriginalFileName as varchar(max),
  @HasElevatedSecurity bit = 0
AS
BEGIN
  SET NOCOUNT ON;
  IF @HasElevatedSecurity = 0 BEGIN
    ...Stick this into a process queue to run with higher priviledges...
    ...code ommited...
    RETURN --Must return so we dont run the rest of the code
  END  
  BULK INSERT ....    
  ...Process the data...
END

所以我們在SET NOCOUNT ON;"之后的那一行添加了raiserror('This is the updated SP with an error!',16,1)"并且用戶仍然收到關于無法訪問 BULK INSERT 的錯誤,但其他所有人都收到了我們提出的錯誤.

So we added "raiserror('This is the updated SP with an error!',16,1)" on the line after "SET NOCOUNT ON;" and the user still got the error about not having access to BULK INSERT but everyone else got the error we were raising.

然后我創建了一個包含這四個參數的表,并用一些插入 SQL 替換了 RAISERROR.一個用戶收到 BULK INSERT 錯誤并且表中沒有記錄,其他所有人都插入記錄并運行該過程而沒有錯誤.在 SQL Profiler 中,所有的 exec 語句都是一樣的.

Then I created a table that has these four paramanters in them and replaced the RAISERROR with some insert SQL. The one user gets the BULK INSERT error and no record in the table, everyone else inserts the record and runs the process without error. In SQL Profiler, all the exec statements are the same.

順便說一句,SQL Profiler 顯示:

BTW, SQL Profiler shows this:

exec BulkLoadSomeData @UserName='User1', @FileName='UNC Path and file name with no special characters', @OriginalFileName='Line the other file name'

推薦答案

根據我們在 EDIT2 下看到的存儲過程代碼和附加信息,我們知道:

Based on the Stored Proc code and additional information that we see under EDIT2 we know that:

  1. 正在調用批量插入
  2. 用戶仍然收到無法訪問 BULK INSERT 的錯誤,但其他所有人都收到了我們提出的錯誤"

某些 T-SQL 函數(例如 OPENQUERY、OPENROWSET、BULK INSERT 等)對安全性進行預驗證.用戶必須具有 INSERT 和 ADMINISTER BULK OPERATIONS 權限,在某些情況下還必須具有 ALTER TABLE,才能執行 BULK INSERT.此外,將驗證用戶的 NTFS/Active Directory 權限(如果使用 Windows 身份驗證)或 SQL Server 服務的登錄身份"帳戶(如果使用 SQL Server 身份驗證)以確保文件可讀.

Certain T-SQL functions (e.g. OPENQUERY, OPENROWSET, BULK INSERT, etc) do pre-validation on security. A User must have INSERT and ADMINISTER BULK OPERATIONS permissions, and in some cases ALTER TABLE, in order to execute BULK INSERT. Additionally, NTFS / Active Directory permissions for the User (if using Windows Authentication) or the "Log On As" Account of the SQL Server Service (if using SQL Server Authentication) will be validated to ensure that the file is readable.

預驗證(或至少我所說的預驗證")發生在調用存儲過程(或函數等)時,而不是在執行每一行時.如果此時發生錯誤,則不會執行 Proc 中的任何代碼,包括 RAISERROR 或 INSERT 到日志表中.

Pre-validation (or at least what I am calling "pre-validation") occurs when the Stored Proc (or Function, etc) is called and not as each line is executed. If an error occurs at this point then none of the code in your Proc will be execute, including the RAISERROR or the INSERT into the log table.

因此,您所看到的行為最可能的原因是出現問題的用戶缺乏 a) 一個或多個所需的 SQL Server 權限,或 b) 適當的 NTFS 權限,或 c)以上都是.

Hence, the most likely cause of the behavior that you are seeing is that the User that has the issue is lacking either a) one or more of the required SQL Server permissions, or b) the appropriate NTFS permissions, or c) all of the above.

鑒于錯誤是關于無法訪問 BULK INSERT,我猜測是該特定用戶缺少一項或多項 SQL Server 權限.

Given that the error was about not having access to BULK INSERT, my guess is that this particular user is missing one or more of the SQL Server permissions.

這篇關于運行舊版本存儲過程的 SQL Server的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 苏州同创电子有限公司 - 四探针测试仪源头厂家 | IP检测-检测您的IP质量 | 今日娱乐圈——影视剧集_八卦娱乐_明星八卦_最新娱乐八卦新闻 | U拓留学雅思一站式服务中心_留学申请_雅思托福培训 | 灰板纸、灰底白、硬纸板等纸品生产商-金泊纸业 | 深圳激光打标机_激光打标机_激光焊接机_激光切割机_同体激光打标机-深圳市创想激光科技有限公司 深圳快餐店设计-餐饮设计公司-餐饮空间品牌全案设计-深圳市勤蜂装饰工程 | 防伪溯源|防窜货|微信二维码营销|兆信_行业内领先的防伪防窜货数字化营销解决方案供应商 | 冷水机,风冷冷水机,水冷冷水机,螺杆冷水机专业制造商-上海祝松机械有限公司 | 青岛侦探调查_青岛侦探事务所_青岛调查事务所_青岛婚外情取证-青岛狄仁杰国际侦探公司 | 包头市鑫枫装饰有限公司| 洛阳装修公司-洛阳整装一站式品牌-福尚云宅装饰 | 浴室柜-浴室镜厂家-YINAISI · 意大利设计师品牌 | 咿耐斯 |-浙江台州市丰源卫浴有限公司 | 专注提供国外机电设备及配件-工业控制领域一站式服务商-深圳市华联欧国际贸易有限公司 | 北京模型公司-军事模型-工业模型制作-北京百艺模型沙盘公司 | 诗词大全-古诗名句 - 古诗词赏析 | 齿轮减速机电机一体机_齿轮减速箱加电机一体化-德国BOSERL蜗轮蜗杆减速机电机生产厂家 | 信阳市建筑勘察设计研究院有限公司 | 密集柜_档案密集柜_智能密集架_密集柜厂家_密集架价格-智英伟业 密集架-密集柜厂家-智能档案密集架-自动选层柜订做-河北风顺金属制品有限公司 | 谷歌关键词优化-外贸网站优化-Google SEO小语种推广-思亿欧外贸快车 | 干式磁选机_湿式磁选机_粉体除铁器-潍坊国铭矿山设备有限公司 | 南京泽朗生物科技有限公司-液体饮料代加工_果汁饮料代加工_固体饮料代加工 | 骨灰存放架|骨灰盒寄存架|骨灰架厂家|智慧殡葬|公墓陵园管理系统|网上祭奠|告别厅智能化-厦门慈愿科技 | Pos机办理_个人商户免费POS机申请-拉卡拉办理网 | 悬浮拼装地板_篮球场木地板翻新_运动木地板价格-上海越禾运动地板厂家 | 天津散热器_天津暖气片_天津安尼威尔散热器制造有限公司 | 钛合金标准件-钛合金螺丝-钛管件-钛合金棒-钛合金板-钛合金锻件-宝鸡远航钛业有限公司 | 小青瓦丨古建筑瓦丨青瓦厂家-宜兴市徽派古典建筑材料有限公司 | 扬尘在线监测系统_工地噪声扬尘检测仪_扬尘监测系统_贝塔射线扬尘监测设备「风途物联网科技」 | 塑胶跑道施工-硅pu篮球场施工-塑胶网球场建造-丙烯酸球场材料厂家-奥茵 | 无线讲解器-导游讲解器-自助讲解器-分区讲解系统 品牌生产厂家[鹰米讲解-合肥市徽马信息科技有限公司] | 西安标准厂房_陕西工业厂房_西咸新区独栋厂房_长信科技产业园官方网站 | 活动策划,舞台搭建,活动策划公司-首选美湖上海活动策划公司 | 包装机传感器-搅拌站传感器-山东称重传感器厂家-济南泰钦电气 | 精密五金加工厂-CNC数控车床加工_冲压件|蜗杆|螺杆加工「新锦泰」 | 冷却塔风机厂家_静音冷却塔风机_冷却塔电机维修更换维修-广东特菱节能空调设备有限公司 | 广州物流公司_广州货运公司_广州回程车运输 - 万信物流 | 油液红外光谱仪-油液监测系统-燃油嗅探仪-上海冉超光电科技有限公司 | 双杰天平-国产双杰电子天平-美国双杰-常熟双杰仪器 | 广东恩亿梯电源有限公司【官网】_UPS不间断电源|EPS应急电源|模块化机房|电动汽车充电桩_UPS电源厂家(恩亿梯UPS电源,UPS不间断电源,不间断电源UPS) | 全自动实验室洗瓶机,移液管|培养皿|进样瓶清洗机,清洗剂-广州摩特伟希尔机械设备有限责任公司 | 智慧物联网行业一站式解决方案提供商-北京东成基业 |