Collections:
sys.sql_modules - Getting View Definitions Back in SQL Server
How To Get the Definition of a View Out of the SQL Server in SQL Server?
✍: FYIcenter.com
If you want get the definition of an existing view back from the SQL Server, you can use the system view called sys.sql_modules, which stores definitions of views and procedures.
The sys.sql_modules holds view definitions identifiable by the object id of each view. The tutorial exercise below shows you how to retrieve the definition of view, "fyi_link_view" by joining sys.sql_modules and sys.views:
USE FyiCenterData;
GO
SELECT m.definition
FROM sys.sql_modules m, sys.views v
WHERE m.object_id = v.object_id
AND v.name = 'fyi_links_top';
GO
definition
-------------------------------------------
CREATE VIEW fyi_links_top (LinkText) AS
SELECT CONVERT(VARCHAR(20),id)
+ ' - ' + CONVERT(VARCHAR(20),counts)
+ ' - ' + url
FROM fyi_links WHERE counts > 1000
(1 row(s) affected)
⇒ Creating a View with Data from Multiple Tables in SQL Server
⇐ Generating CREATE VIEW Scripts on Existing Views in SQL Server
2016-11-05, 5247🔥, 0💬
Popular Posts:
How To Provide Default Values to Function Parameters in SQL Server Transact-SQL? If you add a parame...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To Calculate Age in Days, Hours and Minutes in SQL Server Transact-SQL? On many Web sites, news ...
Is SQL Server Transact-SQL case sensitive? No. Transact-SQL is not case sensitive. Like the standard...
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...