Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2005, 08:22 AM
Registered User
 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how can i execute SQL in UDF

Hi,

i have written a udf in sql server 2000 which will return a sql statement e.g.
"SELECT EMP_NAME FROM EMP_MASTER"
I would like to execute this sql in the same function and would like to use the resultset of this sql statement. how can i get resultset of this sql.


e.g.
i have a function like

CREATE function fncGetLogDrildown(@stablename varchar(255), @scolname varchar(500), @spkcolname varchar(255), @lrecid smallint)
returns varchar(2555)
as
BEGIN

DECLARE
@sSql nvarchar(2500)

SELECT @sSql = 'SELECT ' + convert(varchar(255), @scolname) + ' FROM ' + convert(varchar(500),@stablename) + ' WHERE ' + convert(varchar(255), @spkcolname) + '=' + convert(varchar(50),@lrecid)

return @sSql
END

Now, this function will return me a sql e.g. "SELECT EMP_NAME FROM EMP_MASTER" BUT i require the resultset not a sql statement as string.




Thanks and Regards,
vinod
 
Old March 18th, 2005, 12:51 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47201






Similar Threads
Thread Thread Starter Forum Replies Last Post
SQLExpress: 1.about "Execute sql button" 2.about garaxan SQL Language 1 September 3rd, 2007 07:26 AM
execute sql fishypew SQL Server 2000 4 May 18th, 2005 09:00 AM
sql execute from an include. robprell PHP Databases 1 October 4th, 2004 12:28 PM
how do I execute an SQL update [email protected] VB How-To 1 June 22nd, 2003 06:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.