存儲過程我有一個表稱爲@TempGeog
SQL使用SET語句
Declare @TempGeog table (type VARCHAR(MAX))
DECLARE @statement1 NVARCHAR(MAX)
SET @statement1 = 'insert into #CountyTemp select th.STRLOGRECNO,tt.county from [DC_2010_'[email protected]+'] th
inner join'+ @TempGeog +' tt on th.NAMELSAD10 = tt.county ;'
EXEC (@statement1);
我不能夠使用表@TempGeog
我的語句1中。
Error:Must declare scalar variable "@TempGeog"
我的sql查詢應根據用戶選擇的地理類型動態構建。
如果表被稱爲'@ TempGeog',不該'它只是'內部連接@TempGeog tt'? –
@JoachimIsaksson'@ TempGeog'在我的聲明中不可用。因此,我不是abe執行內部聯接 – user2748161