I need help with a query. In my query I want to pass my table name as parameter. This is my query:
SELECT DISTINCT
CONVERT (varchar, InspectDateTime) AS 'Inspect Date Time',
CONVERT (varchar, SynDateTime) AS 'Sync Date Time',
Employee,
ROUND(OverAllPercentage, 2) AS Grade
FROM
Table_Name
WHERE
(DATEADD(dd, DATEDIFF(dd, 0, InspectDateTime), 0)
BETWEEN
DATEADD(dd, DATEDIFF(dd, 0, @From ), 0) AND
DATEADD(dd, DATEDIFF(dd, 0, @To ), 0))
ORDER BY
'Inspect Date Time'
Here I want to pass the Table_Name as parameter. Please note that this query is already taking two arguments as parameter, namely "@From” and “@To“
If you are working with MS SQL you can do:
and then just call it