Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
somenoob
Posting Yak Master
112 Posts |
Posted - 2011-09-26 : 22:48:44
|
please help. i have a problem:SELECT * FROM OPENQUERY(ServerLinkEODWMain,'select DISTINCT ABBR from DB WHERE ( ''''' + @Filter_ATB + ''''' >= TO_DATE(''2007-05-01'', ''yyyy-MM-dd'') AND ''''' + @Filter_ATB + ''''' < TO_DATE(''2007-06-01'', ''yyyy-MM-dd'') ) AND GATEWAY = ''T''')it return me an error:Msg 102, Level 15, State 1, Line 4Incorrect syntax near '+'.thanks |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-09-26 : 23:53:24
|
you will need to form and execute the entire openquery statement as dynamic sqldeclare @sql varchar(max)select @sql = 'SELECT * FROM OPENQUERY(ServerLinkEODWMain,''select DISTINCT ABBR from DB WHERE . . . . ..exec (@sql) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|