Subscribe to Subscribers
Talk to Webmaster Tony John

Resources » Code Snippets » SQL

How to create a view using procedure in sql?


Posted Date:     Category: SQL    
Author: Member Level: Gold    Points: 10


In this article I have explained about how to create view using Stored Procedure.



 


You can create view in Stored procedure dynamically. In this example I'm going to create view for sys.tables.


create proc CreateView
as
begin
Declare @SQL varchar(max)
set @SQL ='create view TEST1 as Select * from sys.tables'
exec(@SQL)
end

To run Store Procedure :
  
EXEC CreateView


To Select view Table

select * from TEST1





Did you like this resource? Share it with your friends and show your love!


Responses to "How to create a view using procedure in sql?"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Sysstat in SQL Query
    Previous Resource: How to restore Database in sql server
    Return to Resources
    Post New Resource
    Category: SQL


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    How to create a view using procedure in sql?  .  
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.