Referencing a date cell in Excel in an embedded SQL query

Hello everyone,

Sorry this is not just a SQL query but also an Excel query, tell me to go away if this is the wrong forum! :stuck_out_tongue:

I would like to have date parameters (start date and end date) displayed in my Excel workbook and my embedded SQL query to use those dates.

Does anyone know if this is possible and what the syntax would be please?
Thanks so much in advance!

I've done it by having an additional TAB for the Query Parameter, putting a friendly-name on the Cell for each parameter and then including that in the QUERY. Can't remember how I included it in the Query though, and I can't find any of the XLS files in our Code Repository :scream: but our query would definitely be an EXEC MySproc, with some parameters, (rather than just a SQL SELECT statement)

Thanks Kristen, I am not sure what an EXEC MySproc is. If you remember anything please share! :grin:

Its to run a Stored Procedure. So instead of doing, say, SELECT Col1, Col2, ... FROM MyTable WHERE SomeCol = 'XXX' you would instead put that code in a stored procedure (its a bit like a subroutine, or function) and then EXECUTE that Stored Procedure. Usually a Stored Procedure will have one/many parameters so for example for the above SELECT statement the equivalent Stored procedure would be something like:

CREATE PROCEDURE MyProc
    @MyParam1 varchar(10)
AS
    SET NOCOUNT ON

    SELECT Col1, Col2, ... 
    FROM MyTable 
    WHERE SomeCol = @MyParam1
GO