Solved

Return the value of a SQL Server Function in VB Script

Posted on 2008-10-03
2
347 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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