Solved

Return the value of a SQL Server Function in VB Script

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

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.
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now