T-SQL:@variable |内连接| 2数据库
问题描述:
SQL Server 2008 R2 - 2实例中的数据库,Mandant_2
和tlock
。T-SQL:@variable |内连接| 2数据库
我需要一个内部连接的数据库之间的SQL命令@variable
:
DECLARE @t AS TABLE (
c VARCHAR(100)
)
INSERT @t VALUES ('[Mandant_2].[dbo].[tartikel]')
UPDATE tlock.dbo.temp SET Warengruppe = a.kWarengruppe
FROM tlock.dbo.temp d
INNER JOIN @t a ON d.HAN = a.cHAN
我得到一个错误:
Message 207, Level 16, State 1, Procedure spMyStoreProduced, line 39
Invalid column name 'cHAN'.
不幸的是我不知道为什么。
感谢
答
是什么意思最后一行代码中的
INNER JOIN @t a ON d.HAN = a.cHAN
表@t已列名为c,但目前还没有命名,陈柱。 你的意思是说
INNER JOIN @t a ON d.HAN = a.c
概念证明:
只是试试这个
DECLARE @t AS TABLE (
c VARCHAR(100)
)
INSERT @t VALUES ('[Mandant_2].[dbo].[tartikel]')
select cHAN from @T
,你会得到
Msg 207, Level 16, State 1, Line 7
Invalid column name 'cHAN'.
我想加盟条件应该是'd.HAN = a.HAN'在最后一行。 – Explorer