sql server - T-SQL Get View query after "AS" -


i have view name "_report_territories"

if run below query

exec sp_helptext '_report_territories' 

result displays below screen

enter image description here

question:

how can view query after "create view [dbo].[_report_territories] as" ?

any appreciated.

thanks.

put results of sp_helptext in temporary table, make string , need

declare @t table (     [text] nvarchar(max) ) declare @sql nvarchar(max) =''  insert @t  exec sp_helptext 'vcities'  select @sql =@sql+ [text] @t  select substring(@sql,1,charindex('as',@sql)+ len('as')) 

will give you:

create view vcities   

note: solution may unrelevant if view name contains as


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -