As example I will create a temp table:
CREATE TABLE #TembTable
(
Command VARCHAR(max)
)
Insert the values toin the table
INSERT INTO #TembTable (Command)
VALUES ('SELECT @@VERSION AS Version_Name ;'),
('SELECT @@LANGUAGE AS Current_Language;'),
('SELECT @@LANGID AS Language_ID ;'),
('SELECT @@SERVERNAME AS Server_Name;'),
('SELECT @@SERVICENAME AS Service_Name;')
If I select all values
SELECT * FROM #TembTable
Result will show:
SELECT @@VERSION AS Version_Name ;
SELECT @@LANGUAGE AS Current_Language;
SELECT @@LANGID AS Language_ID ;
SELECT @@SERVERNAME AS Server_Name;
SELECT @@SERVICENAME AS Service_Name;
What I am trying to do is to execute each command automatically.
Thanks.
sp_executesqlto execute the dynamic SQL.create view ... as select @@version as version_name, @@language as current_language, ...