I have a table which stores a SQL predefined function, like CONVERT(VARCHAR(10), '2012-08-21 00:16:41.993', 101) in a row/column. While retrieving the result from table, it should run the function and give the final outcome as "2012-08-21", instead right now it returns the same function statement. I am running select (select RunDate from RunDate) and using SQL server database.
Kindly help!!
DECLARE @x TABLE(sql NVARCHAR(255)); INSERT @x(sql) SELECT N'CONVERT(VARCHAR(10), ''2012-08-21 00:16:41.993'', 101)'; INSERT @x(sql) SELECT N'CONVERT(VARCHAR(10), ''2012-08-18 00:16:41.993'', 101)'; DECLARE @sql NVARCHAR(MAX); SELECT @sql = N'SELECT ' + sql FROM @x; EXEC sp_executesql @sql; it's always give me a single result-set, result is : **2012-08-18** My question is, how can i get both the record in single result set?like :2012-08-21 2012-08-18