Solved

Return the value of a SQL Server Function in VB Script

Posted on 2008-10-03
2
365 Views
Last Modified: 2012-08-13
I am looking for a sample vb script that executes a stored scalar function in SQL Server and returns the value into a variable in the calling vb script.  The Sql function returns a varchar and needs to be put in string.
0
Comment
Question by:bnoles
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 22635402
My favorite stored scalar function is GetDate(), but you can use your own.

dim rs
dim cn
dim sSQL
dim sResult

set cn = createobject("ADODB.Connection")
cn.ConnectionString = MyconnectionString
cn.Open

set rs = CreateObject("ADODB.Recordset")

sSQL = "Select GetDate()"

rs.Open sSQL, cn

sResult = rs.Fields(0).Value

0
 

Author Closing Comment

by:bnoles
ID: 31502808
Thank you for the help.  Your example worked perfectly!!!
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question