Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > Re: How to get ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 10 Topic 10974 of 11421
Post > Topic >>

Re: How to get the sql statement of a view? (by running a query or from ado.net)

by Tom van Stiphout <no.spam.tom7744@[EMAIL PROTECTED] > Apr 18, 2008 at 06:36 AM

On Fri, 18 Apr 2008 16:07:46 +1000, "John Sheppard" <spam@[EMAIL PROTECTED]
>
wrote:

(AdventureWorks is a popular sample database)

use AdventureWorks
go
exec sp_helptext 'HumanResources.vEmployee'
go

==>
  
CREATE VIEW [HumanResources].[vEmployee]   
AS   
SELECT   
    e.[EmployeeID]  
    ,c.[Title]  
    ,c.[FirstName]  
    ,c.[MiddleName]  
    ,c.[LastName]  
    ,c.[Suffix]  
    ,e.[Title] AS [JobTitle]   
    ,c.[Phone]  
    ,c.[EmailAddress]  
    ,c.[EmailPromotion]  
    ,a.[AddressLine1]  
    ,a.[AddressLine2]  
    ,a.[City]  
    ,sp.[Name] AS [StateProvinceName]   
    ,a.[PostalCode]  
    ,cr.[Name] AS [CountryRegionName]   
    ,c.[AdditionalContactInfo]  
FROM [HumanResources].[Employee] e  
    INNER JOIN [Person].[Contact] c   
    ON c.[ContactID] = e.[ContactID]  
    INNER JOIN [HumanResources].[EmployeeAddress] ea   
    ON e.[EmployeeID] = ea.[EmployeeID]   
    INNER JOIN [Person].[Address] a   
    ON ea.[AddressID] = a.[AddressID]  
    INNER JOIN [Person].[StateProvince] sp   
    ON sp.[StateProvinceID] = a.[StateProvinceID]  
    INNER JOIN [Person].[CountryRegion] cr   
    ON cr.[CountryRegionCode] = sp.[CountryRegionCode];  




>Weird!
>
>Im using SQL Server 2005 Developer Edition...perhaps I have some kind of 
>security setting set that prevents this...:(
>
>I'll keep mucking around...and re****t back with my findings..
>
>Thanks Tom
>John
>
>"Tom van Stiphout" <no.spam.tom7744@[EMAIL PROTECTED]
> wrote in message 
>news:3j3g04hh6p5a7a2bkj9k274paqktrbvo49@[EMAIL PROTECTED]
>> On Fri, 18 Apr 2008 12:24:17 +1000, "John Sheppard" <spam@[EMAIL PROTECTED]
>
>> wrote:
>>
>> Worked for me on a SQLServer 2005 database.
>> -Tom.
>>
>>
>>>
>>>"Tom van Stiphout" <no.spam.tom7744@[EMAIL PROTECTED]
> wrote in message
>>>news:ksle041h2edhc7bgfquv5696advi785ou7@[EMAIL PROTECTED]
>>>>A quick-n-dirty way is to execute sp_helptext on that view.
>>>>
>>>> -Tom.
>>>
>>>Ahh close! Thanks Tom...
>>>
>>>This works for tables but not for views...:( Google seems to think it 
>>>works
>>>on views tho....is that correct or do I have something weird happening?
>>>
>>>this;
>>>USE BMS;
>>>
>>>GO
>>>
>>>sp_helptext 'bms.dbo.myView', myExpression
>>>
>>>GO
>>>
>>>Outputs the following;
>>>
>>>Msg 15218, Level 16, State 1, Procedure sp_helptext, Line 64
>>>Object 'bms.dbo.myView' is not a table.
>>>
>>>
>>>Thank you
>>>John Sheppard
>>> 
>
 




 10 Posts in Topic:
How to get the sql statement of a view? (by running a query or f
"John Sheppard"  2008-04-17 17:06:49 
Re: How to get the sql statement of a view? (by running a query
Philipp Post <Post.Phi  2008-04-17 02:51:17 
Re: How to get the sql statement of a view? (by running a query
"John Sheppard"  2008-04-18 12:26:38 
Re: How to get the sql statement of a view? (by running a query
Tom van Stiphout <no.s  2008-04-17 06:59:22 
Re: How to get the sql statement of a view? (by running a query
"John Sheppard"  2008-04-18 12:24:17 
Re: How to get the sql statement of a view? (by running a query
Tom van Stiphout <no.s  2008-04-17 19:59:14 
Re: How to get the sql statement of a view? (by running a query
"John Sheppard"  2008-04-18 16:07:46 
Re: How to get the sql statement of a view? (by running a query
Tom van Stiphout <no.s  2008-04-18 06:36:40 
Re: How to get the sql statement of a view? (by running a query
"John Sheppard"  2008-04-21 11:21:30 
Re: How to get the sql statement of a view? (by running a query
"John Sheppard"  2008-04-21 12:24:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 22:23:56 CDT 2008.