When I am passing datetime parameter in OPENROWSET query, I get the following error:
Conversion failed when converting date and/or time from character string
SELECT * FROM OPENROWSET('SQLNCLI',
'SERVER=localhost;UID=test;PWD=test',
'set FMTONLY OFF exec testdatabase.dbo.Proc_Salaryslip_PF '','','','',''5112'','','','','',''8'',''2012'','','',''0'',''1'',A,20120401,20130301,''Y'',''Y'','',A,admin,0,N,'',''18'' ')
Please suggest some solution, my project is depending upon your answer.
These looks suspicious
20120401,20130301. If they are passed to adatetimeparameter you will get:Since you pass them as integer instead of string literal. To fix that you have to quote them as strings.
But since that is not the error you get you are passing another parameter as a string to a
datetimeparameter.Here is the parameter list you use, one row for each parameter. Check against the declaration of your procedure.