How to create view using stored procedure

Hariinakoti
Posted by Hariinakoti under Sql Server category on | Points: 40 | Views : 1617
create proc CreateView
as
begin
Declare @SQL varchar(max)
set @SQL ='create view TEST1 as Select * from sys.tables'
exec(@SQL)
end

run the storedprocedure: EXEC CreateView

Comments or Responses

Posted by: Jasminej on: 9/15/2012 Level:Starter | Status: [Member] | Points: 10
What will happen If I run the Procedure again and again ?

Posted by: T.Saravanan on: 9/15/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi Hari,

Nice question from Jasminej. Please update your proc as rerunable and also post your code inside the code tag.

Login to post response