语法报错,网上说字符串中的变量以'''+@para+'''在字符串中表示,感觉没问题,还是openquery特殊呢?
declare @tagName char(30)
set @tagName = '内河侧水位'
select *from openquery(HH2,'select TOP 1 * from water.rawdata where TAGNAME ='''+@tagName+'''')
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near '+'.
不用openquery就没问题
go
Create Procedure Test
@TestID int
As
Declare @s nvarchar(800)
Set @s='select TOP 1 * from water.rawdata where TAGNAME ='''+@TestID+''''
print @s
exec(@s)
go
咋办啊