In SQL Server, you can use T-SQL to get the definition for a computed column by querying the sys.computed_columns system catalog view.
how to
Change an Existing Column to a Computed Column in SQL Server (T-SQL Example)
This article demonstrates how to use T-SQL to change an existing column to a computed column in SQL Server.
A computed column is a virtual column that uses an expression to calculate its value. The expression will typically use data from other columns. A computed column is not physically stored in the table unless it’s marked PERSISTED.
Add a Computed Column to an Existing Table in SQL Server
This article demonstrates how to use T-SQL to add a computed column to an existing table in SQL Server.
A computed column is a virtual column that uses an expression to calculate its value. The expression will typically use data from other columns. A computed column is not physically stored in the table unless it’s marked PERSISTED.
Create a Computed Column in SQL Server using T-SQL
This article demonstrates how to use T-SQL to create a computed column in SQL Server.
A computed column is a virtual column that uses an expression to calculate its value. The expression will typically use data from other columns. A computed column is not physically stored in the table unless it’s marked PERSISTED.
How to Return a List of Trigger Events in SQL Server
You can use T-SQL to return a list of trigger events in a database in SQL Server.
You can do this using sys.trigger_events. This system catalog view returns a row for each event or event group on which a trigger can fire.
Use IDENT_CURRENT() to Return the Current Identity Value on an Identity Column in SQL Server
In SQL Server, you can use the T-SQL IDENT_CURRENT() function to return the last identity value generated for a specified table or view on an identity column. The last identity value generated can be for any session and any scope.
How to Use the IDENTITY() Property in SQL Server
When you use T-SQL to create (or alter) a table in SQL Server, you have the option of using the IDENTITY() property to create an identity column.
An identity column contains an automatically incrementing identification number. The IDENTITY() property can be used with the CREATE TABLE and ALTER TABLE statements.
How to Use the IDENTITY() Function in SQL Server
In SQL Server, you can use the IDENTITY() function to insert an identity column into a new table.
However, this function is not to be confused with the IDENTITY() property, which is used with the CREATE TABLE and ALTER TABLE statements.
The IDENTITY() function is used only in a SELECT statement with an INTO table clause. So you can use it when transferring data from one table to another, for example.
Set Key/Value Pairs in the Session Context in SQL Server (sp_set_session_context)
In SQL Server, you can use the sp_set_session_context stored procedure to set key/value pairs in the session context.
These key/value pairs then remain in your session context until your connection to SQL Server closes. You can use these values in stored procedures and other T-SQL code throughout the life of your session.
This method for maintaining session state was first introduced in SQL Server 2016. Prior to that release, you would need to use SET CONTEXT_INFO, which provides a similar, but much more limited way of storing session state.
How to Delete Files in SQL Server 2019
In SQL Server 2019, you can use the sys.xp_delete_files stored procedure to delete a file on the file system.
This stored procedure was introduced in SQL Server 2019, and it can be used in conjunction with sys.xp_copy_file and sys.xp_copy_files (both of which were also introduced in SQL Server 2019), which enable you to copy files.
Prior to SQL Server 2019, you would need to use xp_cmdshell, which spawns a Windows command shell and passes in a string for execution. The new stored procedures introduced in SQL Server 2019 allow you to copy and delete files without relying on xp_cmdshell.