2010年10月18日 星期一

已經為連結伺服器 "test" 的提供者 "SQLNCLI" 指定無效的結構描述或目錄

更改了server test 中的某一個table schema

因為資料量很大,所以通常都是先create 新table後,再用匯入匯出精靈將資料轉到新table, 轉換完畢後再將舊的table drop , 然後rename 新table.

以前都直接在Enterprise Manager上做reanme的動作, 但這次改用sp_reanme來更名.

sp_rename 'new_table', 'old_table '

結果今天查詢linkd db時,  select  count(*)  from test.mydb.dbo.old_table

出現了以下的錯誤

已經為連結伺服器 "test" 的提供者 "SQLNCLI" 指定無效的結構描述或目錄。

參考 NSDN這篇文章,

How to set up and troubleshoot a linked server to an Oracle database in SQL Server

里頭提到, 要嗎沒有permission,要嗎就是table name 不存在......

利用 sp_tables_ex  @table_server=test, @table_name='old_table'  

來查看linkdb中的table是否存在, 結果竟然沒有半筆資料......可是table 明明都在啊

直接用select * from openquery (test, 'select count(*) from old_tab') 來查詢,卻又有筆數..
select  count(*)  from test.mydb.dbo.old_table  比較
以結果筆數來說,這二個語法不應該是相同的嗎? 真是沒道理啊....

再來,  select * from sysobjects where name like '%old_table%'

table也是存在的. select 其他table都OK, 唯獨這個table都查不到....WHY????

回頭檢查了一那天跑的sql syntax...

原來 sp_rename 'new_table', 'old_table '  , 'old_table ' 後面多了一個空白, 
這個空白,讓linkdb 不認得了....


sp_tables_ex 執行時, 如果出現

伺服器 'MOJSS' 並未設定給 DATA ACCESS

請執行  exec sp_serveroption 'your server name','data access',true



沒有留言:

張貼留言

IIS 網站無法下載中文檔名檔案因為取消高位元字元

 網址+中文檔案名稱方式下載檔案顯示 404 - 找不到檔案或目錄。 但英數字檔案名稱則可下載。 因為設定GCB IIS,其中1項 將高位元字元預設取消勾選了。 27 TWGCB-04-014-0028 要求篩選與其他限制模組 允許高位元字元 這項原則設定決定查詢...