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



沒有留言:

張貼留言

publish error allowDefinition='MachineToApplication'

一個老舊的aspx web form專案,調了一些功能建置成功,但進行部署時顯示以下錯誤。 在應用程式層級之外使用註冊為 allowDefinition='MachineToApplication' 的區段發生錯誤。錯誤的原因可能是虛擬目錄尚未在 IIS 中設定為...