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
  • 704,970
  • 168
  • 1,303
  • 1,425
V.B
  • 1,181
  • 6
  • 28
  • 51

1 Answers1

2

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
  • 505
  • 5
  • 13