Solved

Dynamic View T-SQL

Posted on 2013-05-22
5
384 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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