Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to retrieve value from MSSQL table into a cell

Hi all

Is it possible to develop a custom function that I could use to
retrieve a field value from a MSSQL database into a cell?

Example # 1

@DBSEEK('00001','Customer','Name')
which would retrieve the custome name of customer ID, 00001 from the
customer table in a MSSQL database.

@DBSUM('Employee','Salary','Department=[ADMIN]')
which would get the sum of salaries of all employees of
department="ADMIN" from the employee table of a MSSQL database


Your advice most appreciated

Best Regards

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default How to retrieve value from MSSQL table into a cell

You could probably do this more simply by using ODBC (MSQuery) to the SQL
database like so

http://www.nickhodge.co.uk/gui/datam...taexamples.htm

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk


wrote in message
oups.com...
Hi all

Is it possible to develop a custom function that I could use to
retrieve a field value from a MSSQL database into a cell?

Example # 1

@DBSEEK('00001','Customer','Name')
which would retrieve the custome name of customer ID, 00001 from the
customer table in a MSSQL database.

@DBSUM('Employee','Salary','Department=[ADMIN]')
which would get the sum of salaries of all employees of
department="ADMIN" from the employee table of a MSSQL database


Your advice most appreciated

Best Regards



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to retrieve value from MSSQL table into a cell

Thanks Nick

Is there a way I could automate this by writing a VBA function that
will access the MSSQL table programatically? Your advise most
appreciated. Thanks

Best Regards


Nick Hodge wrote:
You could probably do this more simply by using ODBC (MSQuery) to the SQL
database like so

http://www.nickhodge.co.uk/gui/datam...taexamples.htm

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk


wrote in message
oups.com...
Hi all

Is it possible to develop a custom function that I could use to
retrieve a field value from a MSSQL database into a cell?

Example # 1

@DBSEEK('00001','Customer','Name')
which would retrieve the custome name of customer ID, 00001 from the
customer table in a MSSQL database.

@DBSUM('Employee','Salary','Department=[ADMIN]')
which would get the sum of salaries of all employees of
department="ADMIN" from the employee table of a MSSQL database


Your advice most appreciated

Best Regards


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default How to retrieve value from MSSQL table into a cell

Sure

I'm not quite sure how far this gets you but if you record a macro doing the
steps outlined in the article, you can adapt this. Alternatively, bear in
mind that once the workbook has a connection to the datasource (whatever
that may be) you can simply re-query from the database by pressing the
Refresh button on the data menu in Excel. (By default this is saved with the
workbook)

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk


wrote in message
oups.com...
Thanks Nick

Is there a way I could automate this by writing a VBA function that
will access the MSSQL table programatically? Your advise most
appreciated. Thanks

Best Regards


Nick Hodge wrote:
You could probably do this more simply by using ODBC (MSQuery) to the SQL
database like so

http://www.nickhodge.co.uk/gui/datam...taexamples.htm

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk


wrote in message
oups.com...
Hi all

Is it possible to develop a custom function that I could use to
retrieve a field value from a MSSQL database into a cell?

Example # 1

@DBSEEK('00001','Customer','Name')
which would retrieve the custome name of customer ID, 00001 from the
customer table in a MSSQL database.

@DBSUM('Employee','Salary','Department=[ADMIN]')
which would get the sum of salaries of all employees of
department="ADMIN" from the employee table of a MSSQL database


Your advice most appreciated

Best Regards




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default How to retrieve value from MSSQL table into a cell

If you understand ADO then you could write a custom function to do what you
need.
You might have to spend some time parsing the parameters to create the SQL
though, depending on how generic you need it to be.

Tim

--
Tim Williams
Palo Alto, CA


wrote in message
oups.com...
Thanks Nick

Is there a way I could automate this by writing a VBA function that
will access the MSSQL table programatically? Your advise most
appreciated. Thanks

Best Regards


Nick Hodge wrote:
You could probably do this more simply by using ODBC (MSQuery) to the

SQL
database like so


http://www.nickhodge.co.uk/gui/datam...taexamples.htm

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk


wrote in message
oups.com...
Hi all

Is it possible to develop a custom function that I could use to
retrieve a field value from a MSSQL database into a cell?

Example # 1

@DBSEEK('00001','Customer','Name')
which would retrieve the custome name of customer ID, 00001 from the
customer table in a MSSQL database.

@DBSUM('Employee','Salary','Department=[ADMIN]')
which would get the sum of salaries of all employees of
department="ADMIN" from the employee table of a MSSQL database


Your advice most appreciated

Best Regards






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using 2 cells in a table to retrieve data from another table Andy G Excel Worksheet Functions 0 March 19th 08 11:12 PM
Can Web Query retrieve a single HTML table cell? Joe Francisco Excel Discussion (Misc queries) 3 April 25th 06 06:18 PM
VB.net/Excel/MSSQL Solution - Help! ColinNOVO Excel Programming 1 August 17th 05 12:29 PM
New to VBS and MSSql Robby Excel Programming 2 December 17th 04 06:55 PM
SQLRequest to MSSQL server - macro chuckiej Excel Programming 2 May 13th 04 04:28 PM


All times are GMT +1. The time now is 07:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"