View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mark[_32_] Mark[_32_] is offline
external usenet poster
 
Posts: 1
Default SQL data access help required?

I've never used excel to do this before (see below), so
i'm at a complete loss abnd could use some guidance.

What i've done so far....

I need to connect to an sql db and retrieve some
information that populates my excel spreadsheet.

In excel (2000), i've gone to "Data/get external data/New
database query", i've connected to my sql server using the
SQL ODBC driver, ok..this bits fine.

I then create an excel query that runs some T-SQL, ok,
this bits fine.

e.g.

DECLARE @month varchar(15)
SET @month = datename(month,dateadd (mm,-1,getdate()))
DECLARE @year varchar (5)
SET @year = datename(year,getdate())
select count(*)
from <Table
where <field=@month
and <field=@year

if i run the query (using microsoft query) it gives me the
correct values, but in my cell within excel it shoes me
nothing but the name of the excel query that is running
and no values?

I seem to be missing something here, can anyone point me
in the right direction?