Solved

Dynamic View T-SQL

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now