日期:2014-05-19  浏览次数:20407 次

怎么操作不同数据库的表?
下面的[AspDotNetStorefront59].[dbo].[syscolumns]   这做法无法得到正确的结果!

select   name   from   [AspDotNetStorefront59].[dbo].[syscolumns]  
where   id=object_id( 'address ')   and   name   not   in(select   name   from   AspDotNetStorefront.dbo.syscolumns   where   id=object_id( 'address '))


(分全扔了!)

------解决方案--------------------
库名..表名
如果连不上,会有提示建立连接服务器
建个链接服务器就可以了
------解决方案--------------------
用sp_addlinkedserver添加一個數據庫連接。
------解决方案--------------------
如果在同一台服务器上,直接用:

数据库名.dbo.表名



数据库名..表名


如:当前库为A,访问B库中的表T_B


select *
from B..T_B

------解决方案--------------------
在object_id是不是要这么写。。object_id(N '[servername].[dbo].[tablename] ')