select ? as an input parameter | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

select ? as an input parameter

I am trying to pass a calculated date to my SQL task by using the syntax: SELECT ?, ANY_COLUMN FROM MYTABLE I get the error message ‘Syntax error or access violation’. The date would ordinarily be today except on Saturdays when I bump it to the following Monday. Can’t I do this? What is the syntax error?
try this
SELECT getdate(),column from table
I don’t want getdate(). I want the date I’ve calculated.
declare @var1 datetime
select @var1=getdate()–or the way u r calculating
select @var1,column from table
I’m sorry – I’ve stated my problem poorly. I can think of a number of work arounds including the ones suggested but I want to be able to use the input parameter for a SQL statement. I believe the statement Select count(*) from mytable where name=? will allow for a specified global variable to be the input parameter substituted for the question mark. I thought the same would be true for my query above where the question mark is in the select, not the where clause. I want to know if I’m making a syntax error or is it some other problem.
I think it is only possible to pass parameters to stored procedure execution. I am not quite sure about that, but you can try and see if it helps.