How to Connect to an Instance Name Using SMO
1. Create your Visual Studio Project
2. Add the following references in your project
- Microsoft.SqlServer.ConnectionInfo
- Microsoft.SqlServer.Smo
- Microsoft.SqlServer.SmoEnum
- Microsoft.SqlServer.SqlEnum
3. Include the following using statement:
using Microsoft.SqlServer.Management.Smo;
4. Add your server object. Normally, you would use the following format in your Server object:
String serverName = "JUBILEE";
Server srv = new Server(serverName);
Database db = srv.Databases["AdventureWorks"];
txtServerInfo.Text = srv.Information.VersionString +
System.Environment.NewLine;
However, if you have an instance name, you have to specify the SERVER\INSTANCE name in your Server object. In C# code:
String serverName = “JUBILEE” + @”\” + “SQL01“;
Server srv = new Server(serverName);
Database db = srv.Databases["AdventureWorks"];
txtServerInfo.Text = srv.Information.VersionString +
System.Environment.NewLine;
Valid SQLXML XSD Data Types, and Sample SQL Server XML Schemas
Here is a partial list of valid XSD data types for SQL Server 2005:
| xsd:int or xsd:integer |
| xsd:decimal |
| xsd:date |
| xsd:dateTime |
| xsd:string |
| xsd:base64Binary |
Note that in SQL Server 2005, the timezone needs to be included in the date or dateTime element or attribute value, for example:
<Authors>
<Author AuthorID="1" FirstName="John" LastName="Doe"
IsIndependent="true"
DateJoined="1992-05-01Z" DateTimeJoined="1992-05-01T00:00:00Z"/>
</Authors>
Note the existence of the letter Z at the end of the date and datetime attributes.
Microsoft also provided a list of schemas in http://schemas.microsoft.com/sqlserver/. It includes the following AdventureWorks sample schemas:
- AdventureWorks Customer Contact Information Schema
- AdventureWorks Customer Contact Record Schema
- AdventureWorks Customer Contact Type Schema
- AdventureWorks Consumer Demographics Survey Schema
- AdventureWorks Product Catalog Schema
- AdventureWorks Manufacturing Instructions Document Schema
- AdventureWorks Product Warranty and Maintenance Information Schema
- AdventureWorks Standard Resume Schema
- AdventureWorks Retail Stores Demographics Survey Schema

