Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a SQL Server module?

Tags:

sql-server

I just came across the system view sys.sql_modules today. What is a module versus a DB object? The view returns, most prominently, a column containing the definition text, as returned by sys.syscomments.

like image 523
ProfK Avatar asked Apr 08 '09 18:04

ProfK


1 Answers

A module, in SQL-Server-speak is a stand-alone object that contains sql batches, such as a view, table valued function, stored procedure, trigger or scalar function. A SQL object is a more all-encompassing term that includes some that contain SQL Expressions, such as check or default constraints. A module used to be referred to as a 'routine' before SQL Server 2005, but I think the two terms are used interchangeably.

The table build script is not stored in SQL Server because of the ease with which components of a table can be altered separately. Therefore it is treated as an object but not a module.
Typical objects that aren't also considered to be modules are system tables, default constraints, foreign key constraints, service queues, check constraints, user tables, primary key constraints, internal tables and unique constraints.

Columns aren't considered to be objects. Neither are indexes.

Yes, it is all more complex than one might first think.

like image 174
Phil Factor Avatar answered Oct 12 '22 02:10

Phil Factor