Solved

Dynamic View T-SQL

Posted on 2013-05-22
5
391 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 334 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 166 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 334 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 how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Backup & Restore 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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

623 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