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
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
Post a Comment