Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dynamic View T-SQL

Posted on 2013-05-22
5
Medium Priority
?
402 Views
Last Modified: 2013-05-24
I came across info on Dynamic Views in T-SQL.  I am unclear on what they are (it is a view with dynamic code ?) and when they can be used.   Thanks for any feedback.
0
Comment
Question by:fjkaykr11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 57

Assisted Solution

by:Raja Jegan R
Raja Jegan R earned 1336 total points
ID: 39189839
No, its not dynamic views but it is Dynamic Management Views and more details from MSDN below:
http://msdn.microsoft.com/en-us/library/ms188754%28v=sql.110%29.aspx
0
 
LVL 16

Assisted Solution

by:Surendra Nath
Surendra Nath earned 664 total points
ID: 39189862
As said by rrjegan17, there are no dynamic views in SQL Server....

As far as I know a View definition dont accept dynamic code....

But at the time of creation of a view you can create it dynamically, probably you are looking one of such thing and saying that as a dynamic view.

For example:

declare @tableName varchar(50)
set @tableName = 'abcd'
declare @sql varchar(2000)
set @sql = 'create view viw_'+@tableName + ' as Select * from ' + @TableName
exec(@sql)

Open in new window


the above code will create a view dynamically for you, depending on the variables...
0
 
LVL 3

Author Comment

by:fjkaykr11
ID: 39193103
thanks for the replies. In this MSDN link they refer to Dynamic Views (do they really mean Dynamic View Management) ?
http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/558edef0-9618-438e-b670-f421c0ecac92/
0
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 1336 total points
ID: 39193366
No, its Dynamic SQL and not Dynamic Views..
Either you can create a view or do any operation with Dynamic SQL as mentioned by Neo_jarvis also above..
For a good start on Dynamic SQL you can use the below link:
http://www.benkotips.com/pages/DynamicSQL.aspx

But be a bit careful while using Dynamic SQL since the code is not parsed until it is executed, and it can potentially introduce security vulnerabilities that you do not want.
0
 
LVL 3

Author Closing Comment

by:fjkaykr11
ID: 39195135
Thanks for clarifying this. I appreciate the feedback.
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question