我从 Linq To SQL 开始,摆弄 Linqpad,我试图复制一个 SQL 脚本,该脚本连接同一服务器上不同数据库中的表(SQL Server 2008)。
TSQL 查询大致如下所示:
using MainDatabase
go
insert Event_Type(code, description)
select distinct t1.code_id, t2.desc
from OtherDatabase..codes t1
left join OtherDatabase..lookup t2 on t1.key_id = t2.key_id and t2.category = 'Action 7'
where t2.desc is not null
我基本上是想弄清楚如何进行跨数据库插入。这对 Linq To SQL 是否可行(在 Linqpad 中是否可行?)