I stuck in a scenario. Can somebody help me out.
I have a table contains column Id, FncName
Id column contains integer value and FncName contains Scalar Function name.
I want to select a row from table and in result set I need the result of execution of that function. Sample data is given below:
CREATE TABLE AA (Id INT, FncName VARCHAR(255))
INSERT INTO AA VALUES (1,'aa_utcdate')
INSERT INTO AA VALUES (2,'aa_date')
CREATE FUNCTION aa_utcdate ()
DECLARE @A DATETIME
SELECT @A = GETUTCDATE()
CREATE FUNCTION AA_DATE ()
DECLARE @A DATE
SELECT @A = GETDATE()
-- Query to execute
SELECT id,exec(FncName) FROM AA
-- Result Set Required
1, 2013-11-13 10:08:01.860
2, 2013-11-13 15:08:01.863
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!