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
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With