How to: Create a SQL Server Project
SQL Server projects in Visual Studio assist in the creation of stored procedures, triggers, aggregates, user-defined functions, and user-defined types using .NET Framework languages such as Visual Basic, Visual C#, and Visual C++.
Note
SQL Server projects require a reference to SQL Server 2005 or later.
Note
The common language runtime (CLR) integration feature is off by default in Microsoft SQL Server and must be enabled in order to use SQL Server project items. To enable CLR integration, use the clr enabled option of the sp_configure stored procedure. For more information, see Enabling CLR Integration.
After creating a SQL Server project, create the database objects you want to deploy to the SQL Server. The following table provides links to Help topics that describe how to create the available database objects:
Database Object |
Information |
---|---|
Stored Procedure |
|
Trigger |
|
Aggregate |
|
User-defined Function |
How to: Create and Run a CLR SQL Server User-Defined Function |
User-defined Type |
Note
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.
Creating a New Project
To create a new SQL Server project
From the File menu, create a new project.
In the New Project Dialog Box, select and expand a language node in the Project Types area.
Select the Database node.
Select the SQL Server Project template.
Click OK.
Connecting to a SQL Server Database
SQL Server projects require a connection to a database running on SQL Server 2005 or later. If connections to SQL Server 2005 databases are available in Server Explorer, then they will be listed in the Add Database Reference dialog box.
To connect to a SQL Server 2005 database
Connect to a SQL Server 2005 database or later by completing the Add/Modify Connection Dialog Box. For more information, see Add/Modify Connection (Microsoft SQL Server).
-or-
Select an existing database connection in the Add Database Reference Dialog Box to use for the SQL Server project. For more information, see Add Database Reference Dialog Box.
See Also
Tasks
How to: Create a SQL Server Project
How to: Create and Run a CLR SQL Server Stored Procedure
How to: Create and Run a CLR SQL Server Trigger
How to: Create and Run a CLR SQL Server Aggregate
How to: Create and Run a CLR SQL Server User-Defined Function
How to: Create and Run a CLR SQL Server User-Defined Type
Walkthrough: Creating a Stored Procedure in Managed Code
How to: Debug a SQL CLR Stored Procedure
Concepts
Introduction to SQL Server CLR Integration (ADO.NET)
Advantages of Using Managed Code to Create Database Objects
Item Templates for SQL Server Projects
Reference
Attributes for SQL Server Projects and Database Objects