Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Return the value of a SQL Server Function in VB Script

Posted on 2008-10-03
2
Medium Priority
?
371 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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