Solved

Return the value of a SQL Server Function in VB Script

Posted on 2008-10-03
2
323 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
Comment Utility
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
Comment Utility
Thank you for the help.  Your example worked perfectly!!!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 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

9 Experts available now in Live!

Get 1:1 Help Now