1

I have following SQL query in SQL Server 2008

Select * from
    (Select T.Col1, T.Col2 
     from openquery('server','select * from table 1 where date= '+ @StartDate +') R

Where @StartDate is a parameter. I get an error that incorrect syntax near '+' expecting ')'

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
V.B
  • 1,191
  • 7
  • 29
  • 55

1 Answers1

3

This is a duplicate post.

The short answer is OPENQUERY does not accept variables for its arguments. See: including parameters in OPENQUERY for a possible workaround.

Community
  • 1
  • 1
Mentatmatt
  • 515
  • 5
  • 13