You can write stored procedures, user-defined functions, aggregates, triggers, and UDTs using managed code hosted by the SQLCLR.
The SQLCLR does not replace Transact-SQL. Set-based operations are best accomplished using T-SQL, whereas computation-intensive operations are best done using the SQLCLR.
You must enable the SQLCLR to use it on the SQL Server instance.
The SqlContext object provides access to the SQLCLR environment. This object has the Pipe property, which sends messages and data to the client.
The SqlContext object's Pipe property also contains the SendResultsStart, SendResultsRow, and SendResultsEnd methods that are used for sending rowset data back to the client.
You can write your SQLCLR source code with a text editor, compile it using the command-line compiler, and load and register the SQLCLR code using SQL scripts. Visual Studio .NET provides a developer-friendly interface that simplifies coding, deployment, and debugging.
You should use the context connection to access data within the current database because the context connection runs in-process and does not use any of the protocol stacks to communicate with the database server.
You should use a UDT only to define an atomic value that will be viewed in a column, not to represent business objects such as customers and employees.