Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grabbing 'View' code 1

Status
Not open for further replies.

DaveJunior

Programmer
Jan 7, 2003
11
0
0
GB
I am an ASP programmer and need to grab the SQL code for a view within a database.

Can anyone tell me if this is even possible or better still, how to do it.

cheers.
 
sp_helptext <view_name>

RT
 
That works great for any view that I create on the server as DBO, however, I also have some views that were created through ADODB in ASP. These have an owner of [NT AUTHORITY\ANONYMOUS LOGON] and I cannot reference them in any of the following ways:

sp_helptext myView

sp_helptext [NT AUTHORITY\ANONYMOUS LOGON].myView

sp_helptext CMP.[NT AUTHORITY\ANONYMOUS LOGON].myView

Any ideas?
 
There are two options to do this.

1. Login as the anonymous user and then use the sp_helptext to get the code of the view.

2. The other method is to dig into the system tables as follows

select id from sysobjects where name = <your view name>

Once you have this id

select text from syscomments where id = <id of your view>

RT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top