SQL Server 2000 provides programming samples that demonstrate how to use a number of different technologies with a variety of programming languages. You can install these as part of a custom installation.
You can use the following table to view all available samples, or you can select a specific category by clicking the Technology down arrow and making a specific selection (for example, Replication). You can also sort the table by clicking a column heading (for example, Language). To view detailed information about a specific sample, click the text in the Sample column.
ADOEmployeeMS-ITS:adosql.chm::/adoprg04_9nc9.htmVisual BasicDisplays long data types using the Employees table in the Northwind database.ADOEmployeeMS-ITS:/adosql.chm::/adoprg04_1sa1.htmC++Displays long data types using the Employees table in the Northwind database.ADOFORXMLMS-ITS:adosql.chm::/adoprg04_92gc.htmXMLBuilds an Active Server Page (ASP) that retrieves result sets into streams.ADOIntroMS-ITS:adosql.chm::/adoprg04_5iw7.htmVisual BasicConnects to and queries a SQL Server database. Also shows error handling.ADOOpenXMLMS-ITS:adosql.chm::/adoprg04_15ik.htmXMLBuilds an Active Server Page (ASP) that maps an XML schema to a relational schema.ADOXpathMS-ITS:adosql.chm::/adoprg04_21vd.htmXMLBuilds an Active Server Page (ASP) that performs an xpath query.ADOWebMS-ITS:adosql.chm::/adoprg04_85ym.htmWebBuilds Active Server Page (ASP)that interacts with instance of SQL Server.Analysis ServicesAspAdoComplexMS-ITS:olapdmpr.chm::/prsamples_1rji.htmVBScriptCreates and manipulates a query-based cube.Analysis ServicesAspAdoCubeDocMS-ITS:olapdmpr.chm::/prsamples_6p7y.htmVBSCriptRetrieves and manipulates a cube schema.Analysis ServicesAspAdoCubeTreeMS-ITS:olapdmpr.chm::/prsamples_6p7y.htmVBScript,JScriptRetrieves and manipulates a cube schema.Analysis ServicesAspAdoSimpleMS-ITS:olapdmpr.chm::/prsamples_1rji.htmVBScriptCreates and manipulates a query-based cube.Analysis ServicesCppOlapDemoMS-ITS:olapdmpr.chm::/prsamples_1rji.htmC++Creates and manipulates a query-based cube.Analysis ServicesVbAdoComplexMS-ITS:olapdmpr.chm::/prsamples_1rji.htmVisual BasicCreates and manipulates a query-based cube.Analysis ServicesVbAdoCreateCubeMS-ITS:olapdmpr.chm::/prsamples_96zy.htmVisual BasicCreates a client-side cube.Analysis ServicesVbAdoCubeDocMS-ITS:olapdmpr.chm::/prsamples_6p7y.htmVisual BasicRetrieves and manipulates a cube schema.Analysis ServicesVbAdoSimpleMS-ITS:olapdmpr.chm::/prsamples_1rji.htmVisual BasicCreates and manipulates a query-based cube.Analysis ServicesVbDsoCreateSmallCubeMS-ITS:olapdmpr.chm::/prsamples_63ou.htmVisual BasicCreates and manipulates a complex cube.Analysis ServicesVbDSOExampleMS-ITS:olapdmpr.chm::/prsamples_96zy.htmVisual BasicCreates a server-side cube.Analysis ServicesVbAdoWriteBackMS-ITS:olapdmpr.chm::/prsamples_63ou.htmVisual BasicCreates and manipulates a complex cube.Analysis ServicesVbDsoWriteEnableCubeMS-ITS:olapdmpr.chm::/prsamples_63ou.htmVisual BasicCreates and manipulates a complex cube.Analysis ServicesVbMdHTMLdllMS-ITS:olapdmpr.chm::/prsamples_63ou.htmVisual BasicCreates and manipulates a complex cube.DB LibraryExample8MS-ITS:dblibc.chm::/dbc_db_csamp_3k6r.htmC++Shows DB Library support for output parameters in Microsoft SQL Server stored procedures.DB LibrarySqlexampMS-ITS:dblibc.chm::/dbc_db_csamp_8gvn.htmC++Shows how to handle various data types for consistent output.DB LibrarySqltestcMS-ITS:dblibc.chm::/dbc_db_csamp_2tpj.htmC++Issues a simple SELECT statement and prints the returned result set rows to the console.DB LibrarySqltestnMS-ITS:dblibc.chm::/dbc_db_csamp_71pq.htmC++Connects to a database and executes a SELECT statement from the Microsoft(r) Windows NT(r) graphical user interface.DB LibraryTextcopyMS-ITS:dblibc.chm::/dbc_db_csamp_67dt.htmC++Illustrates how to handle Microsoft SQL Server text and image data types from a Microsoft Foundation Class (MFC) console.Desktop EngineDesktop Engine installlationMS-ITS:distsql.chm::/distsql_9zad.htmC++Installs an instance of the Desktop Engine.DTSCustomTaskNoUIMS-ITS:dtsprog.chm::/dtspsamp_7u3t.htmActive Template Library (ATL)ATL template for a DTS custom task that does not support a custom user interface, but instead uses the default property grid in DTS Designer.DTSCustomTaskWithUIMS-ITS:dtsprog.chm::/dtspsamp_0dk9.htmActive Template Library (ATL)ATL template for a DTS custom task that supports a custom user interface.DTSCustomTransformMS-ITS:dtsprog.chm::/dtspsamp_9tkd.htmActive Template Library (ATL)ATL template for a DTS custom transformation.DTSDTSActiveScriptTaskMS-ITS:dtsprog.chm::/dtspsamp_76p7.htmVisual BasicRuns a VBScript as part of a DTS Task.DTSDTSAppObjectMS-ITS:dtsprog.chm::/dtspsamp_91ys.htmVisual BasicUses DTS application object on the local server.DTSDTSApplicationObjectMS-ITS:\dtsprog.chm::/dtspsamp_4a7o.htmVisual BasicGets information from the DTS Application object.DTSDTSBulkInsertTaskMS-ITS:dtsprog.chm::/dtspsamp_14iz.htmVisual BasicUses DTS to do a Bulk Insert from a flat text file.DTSDTSCopyMS-ITS:dtsprog.chm::/dtspsamp_0k55.htmC++Copies a single source column of any simple type into a destination column of the same type.DTSDTSCopyDatabaseMS-ITS:dtsprog.chm::/dtspsamp_5pnp.htmVisual BasicUses the DTS TransferObjectsTask object to copy a database.DTSDTSExecProcessMS-ITS:dtsprog.chm::/dtspsamp_9ik3.htmVisual BasicRuns a Win32 application from a DTS task.DTSDTSExecSQLTaskMS-ITS:dtsprog.chm::/dtspsamp_2ip7.htmVisual BasicExecutes a SQL statement while running a DTS package.DTSDTSExecutePackageMS-ITS:dtsprog.chm::/dtspsamp_6jvp.htmVisual BasicExecutes programmatically a DTS package that has been saved to structured storage (i.e. .dts file).DTSDTSexmp1MS-ITS:dtsprog.chm::/dtspsamp_5wvn.htmVisual BasicCopies data from a source table to a destination table.DTSDTSexmp2MS-ITS:dtsprog.chm::/dtspsamp_7zcc.htmVisual BasicCopies database to Microsoft Excel spreadsheet and creates pivot table; also creates a DTS package.DTSDTSexmp3MS-ITS:dtsprog.chm::/dtspsamp_3ur7.htmVisual BasicCreates a package supporting multiple sources and destinations.DTSDTSFTPTaskMS-ITS:dtsprog.chm::/dtspsamp_6ai3.htmVisual BasicUses DTS to copy files external to SQL Server from a source to a destination.DTSDTSPackageInfoMS-ITS:dtsprog.chm::/dtspsamp_5rov.htmVisual BasicGets information using the DTS Application GetPackageInfos method.DTSDTSStringsMS-ITS:dtsprog.chm::/dtspsamp_47n7.htmC++Reformats two source columns.DTSDTStaskMS-ITS:dtsprog.chm::/dtspsamp_72qz.htmC++Creates and registers a CreateProcessTask COM object.DTSDTSTransferObjectsTaskMS-ITS:dtsprog.chm::/dtspsamp_65yj.htmVisual BasicUses DTS to transfer various types of SQLServer objects from a pubs database to a pubs2 database.DTSDTSTskGVUpdateMS-ITS:dtsprog.chm::/dtspsamp_12lh.htmC++Displays and allows the user to update the value of a global variable.DTSDTSTskPropIconMS-ITS:dtsprog.chm::/dtspsamp_9f3i.htmC++Displays a message whose text is specified as a custom task property.DTSDTSvbpkgMS-ITS:dtsprog.chm::/dtspsamp_5ns3.htmVisual BasicBuilds and executes a DTS package.DTSDTSxformMS-ITS:dtsprog.chm::/dtspsamp_74h1.htmC++Creates and registers a custom Transformation object.DTSFoodMart2000MS-ITS:dtsprog.chm::/dtspsamp_7smo.htmVisual BasicUses the Visual Basic file output from the DTS import/export wizard to convert the FoodMart 2000.mdb database to SQLServer.DTSPackagesMS-ITS:dtsprog.chm::/dtspsamp_0f8z.htmC++Creates and registers a custom Transformation object.DTSPub2PubsMS-ITS:dtsprog.chm::/dtspsamp_2m7n.htmVisual BasicCopies the authors table from the 'pubs' database to the 'pubs2' database, while doing some operations on various fields.Embedded SQLEdlibMS-ITS:esqlforc.chm::/ec_6_eex_00_9o36.htmCUses GET CONNECTION to obtain the DB-Library DBPROCESS connection pointer.Embedded SQLEmbedded SQL for C ExamplesMS-ITS:esqlforc.chm::/ec_6_eex_00_6376.htmC8 examples using C to connect to a specified instance of MicrosoftSQL Server and execute a series of Embedded SQL statements.Embedded SQLGencharMS-ITS:esqlforc.chm::/ec_6_eex_00_4uya.htmCIssues a SELECT statement query from the authors table in the pubs database.Embedded SQLGenwinMS-ITS:esqlforc.chm::/ec_6_eex_00_2a7m.htmCIssues a SELECT statement query from the authors table in the pubs database.Extended Stored Procedurexp-dblibMS-ITS:odssql.chm::/ods_6_sam_01_4xia.htmCUses DB Library to open bound connection to same SQL Server that called the extended stored procedure.Extended Stored Procedurexp-helloMS-ITS:odssql.chm::/ods_6_sam_01_060f.htmCDisplays "hellow world" in output row.Extended Stored Procedurexp-ODBCMS-ITS:odssql.chm::/ods_6_sam_01_9jkz.htmCUses ODBC to open bound connection to same SQL Server that called the extended stored procedure.Extended Stored Procedurexp-paramMS-ITS:odssql.chm::/ods_6_sam_01_4yel.htmCAccepts parameters from Transact-SQL script and reports values.MS DTCDB LibraryMS-ITS:samples.chm::/samp_msdtc_5a79.htmC++Shows how to use MS-DTC in a C++ program.MS DTCODBCMS-ITS:samples.chm::/samp_msdtc_5tnp.htmC++Shows how to use MS-DTC in a C++ program, using ODBC.MS DTCT-SQLMS-ITS:samples.chm::/samp_msdtc_26hx.htmTransact-SQLShows how to use MS-DTC in a Transact-SQL script.ODBCbcpMS-ITS:odbcsql.chm::/od_odbcsamp_4pm8.htmC++Uses bulk copy functions with ODBC driver.ODBCComputeMS-ITS:odbcsql.chm::/od_odbcsamp_7yb7.htmC++Executes SELECT statement, then determines shape of each result set generated.ODBCLoaddataMS-ITS:odbcsql.chm::/od_odbcsamp_74rl.htmC++Loads data into SQL Server table.ODBCMfcperfMS-ITS:odbcsql.chm::/od_odbcsamp_7xly.htmC++Tunes MFC ODBC database classes for performance, and captures and interprets Microsoft SQL Server ODBC driver performance data.ODBCTransMS-ITS:odbcsql.chm::/od_odbcsamp_8037.htmC++Uses cursors to enable concurrent data access.OLE AutomationGetnpvMS-ITS:samples.chm::/samp_oleauto_04md.htmVisual BasicRetrieves net present value.OLE AutomationLoopback (DAO)MS-ITS:samples.chm::/samp_oleauto_7x45.htmVisual BasicRetrieves contents of the input table name provided to the DAO table and returns a tabular array equivalent to the result set returned from SQL Server.OLE AutomationLoopback (RDO)MS-ITS:samples.chm::/samp_oleauto_5lyd.htmVisual BasicUses RDO to call SQL Server and retrieve the contents of the authors table; returns a tabular array equivalent to the result set returned from SQL Server.OLE AutomationTraverseMS-ITS:samples.chm::/samp_oleauto_5t2d.htmTransact-SQLTraverses an object hierarchy.ReplicationDeflt_spMS-ITS:replprog.chm::/rp_replsamp_446q.htmTransact-SQLBuilds a custom stored procedure resolver.ReplicationDistsampMS-ITS:replprog.chm::/rp_replsamp_2pf2.htmC++Shows how to include the SQL Merge and SQL Distribution controls in a custom application.ReplicationRepldtsMS-ITS:replprog.chm::/rp_replsamp_3l0j.htmVisual BasicCreates a transformation subscription.ReplicationReplsampMS-ITS:replprog.chm::/rp_replsamp_5uwe.htmHTMLShows how to include the SQL Merge and SQL Distribution controls in a custom application.ReplicationReplsamp.vbpMS-ITS:replprog.chm::/rp_replsamp_7yr2.htmVisual BasicShows how to include the SQL Merge and SQL Distribution controls in a custom application.ReplicationSamppubMS-ITS:replprog.chm::/rp_replsamp_2mr3.htmTransact-SQLConfigures a third-party publication and distributor.ReplicationSubspresMS-ITS:replprog.chm::/rp_replsamp_6p5x.htmC++Builds a custom stored procedure resolver that executes the stored procedure at the Subscriber.Replicationxp_enumntusersMS-ITS:replprog.chm::/rp_replsamp_3rsj.htmC++Generates multiple merge dynamic snapshot jobs.SQL-DMOAxSQLDMOCtlMS-ITS:sqldmo.chm::/dmoref_ex01_3uy4.htmVisual BasicCreates a UserControl.SQL-DMOBackRestEventsMS-ITS:sqldmo.chm::/dmoref_ex01_0kix.htmVisual BasicBacks up and restores a database.SQL-DMOBackRestEventsMS-ITS:sqldmo.chm::/dmoref_ex01_01gp.htmC++Backs up and restores a database.SQL-DMOBackupDeviceMS-ITS:sqldmo.chm::/dmoref_ex01_325h.htmVisual BasicUses BackupDevice object to add and remove a backup device.SQL-DMOCreateDatabaseMS-ITS:sqldmo.chm::/dmoref_ex01_0bs5.htmVisual BasicCreates a database.SQL-DMOCreateTableMS-ITS:sqldmo.chm::/dmoref_ex01_5w11.htmVisual BasicUses SQL-DMO objects to create and alter tables.SQL-DMODMOExplorerMS-ITS:sqldmo.chm::/dmoref_ex01_53ci.htmVisual BasicWalks the DMO object model and shows the values in it.SQL-DMODmopingMS-ITS:sqldmo.chm::/dmoref_ex01_82pl.htmC++Determines version of SQL Server instance.SQL-DMOEnumsMS-ITS:sqldmo.chm::/dmoref_ex01_8roz.htmVisual BasicUses SQL Server enumeration methods and recordsets.SQL-DMOExploreMS-ITS:sqldmo.chm::/dmoref_ex01_5a3p.htmVisual BasicDisplays contents of collections and properties of objects in SQL-DMO object tree.SQL-DMOIdxtestMS-ITS:sqldmo.chm::/dmoref_ex01_3cc4.htmVisual BasicTests optimization strategies for stored procedures and views.SQL-DMOLoginMS-ITS:sqldmo.chm::/dmoref_ex01_0b72.htmVisual BasicLocates available SQL Servers and logs in to them.SQL-DMORegistryMS-ITS:sqldmo.chm::/dmoref_ex01_7gxl.htmVisual BasicFinds registry information about a specified SQL Server.SQL-DMOServiceMS-ITS:sqldmo.chm::/dmoref_ex01_04yt.htmVisual BasicChecks status of, starts, and stops the service.SQL-DMOSmartptrMS-ITS:sqldmo.chm::/dmoref_ex01_07oy.htmC++Uses Microsoft Visual C++ features to optimize size of program and speed of development.SQL-DMOSocMS-ITS:sqldmo.chm::/dmoref_ex01_40tf.htmCShows how to use C for SQL-DMO development.SQL-DMOSocppMS-ITS:sqldmo.chm::/dmoref_ex01_74kw.htmC++Shows how to use C++ for SQl-DMO development.SQL-DMOSQLScriptsMS-ITS:sqldmo.chm::/dmoref_ex01_13sj.htmVisual BasicShows how to generat SQL scripts to regenerate SQLServer objects.SQL-DMOVerifyBackupMS-ITS:sqldmo.chm::/dmoref_ex01_3t80.htmVisual BasicFinds backup devices and verifies backup set.SQL-NSDbpropMS-ITS:sqlns.chm::/ns_samp_6x2a.htmC++Displays Properties dialog for Pubs database.SQL-NSDumptreeMS-ITS:sqlns.chm::/ns_samp_5t7p.htmC++Dumps all objects in the SQL namespace tree.SQL-NSBrowseMS-ITS:sqlns.chm::/ns_samp_2h82.htmVisual BasicCreates browser for viewing and manipulating SQL namespace.SQL-NSDbpropMS-ITS:sqlns.chm::/ns_samp_85gj.htmVisual BasicDisplays Properties dialog for Pubs database.User Defined FunctionsCustNamesInRegionMS-ITS:samples.chm::/samples_1far.htmTransact-SQLCreates an in-line user-defined function in the Northwind database to view customer information for specific regions from the Customers table.User Defined FunctionsFindReportsMS-ITS:samples.chm::/samples_1far.htmTransact-SQLQueries the Employees table in the Northwind database and shows all direct and indirect reports.User Defined FunctionsLargeFreightMS-ITS:samples.chm::/samples_1far.htmTransact-SQLCreates a user-defined function that queries the Shippers and Orders tables in the Northwind database and returns orders with freight greater than a certain value.User Defined FunctionsMyDateMS-ITS:samples.chm::/samples_1far.htmTransact-SQLChanges the format in which the date is returnedUtilitiesBiiMS-ITS:samples.chm::/samples_2isp.htmExecutable utiiityMimics the bcp utility, but adds additional functinality.UtilitiesPbalanceMS-ITS:samples.chm::/samples_9h9h.htmC++Displays process information for instances of Microsoft(r) SQL Server(tm) 2000 running on a local computer,and manages process priorities.Virtual Backup DeviceMprocessMS-ITS:samples.chm::/samples_2p0z.htmC++Demonstrates a multiple stream Backup or Restore, in which each stream is handled by a secondary process..Virtual Backup DeviceMthreadMS-ITS:samples.chm::/samples_0b38.htmC++Demonstrates a multiple stream Backup or Restore from a single process.Virtual Backup DeviceOsimpleMS-ITS:samples.chm::/samples_2j51.htmC++Demonstrates how to backup or restore a database across an ODBC connection.Virtual Backup DeviceSimpleMS-ITS:samples.chm::/samples_4rfp.htmC++Demonstrates how to backup or restore a database.Virtual Backup DeviceSnapshotMS-ITS:samples.chm::/samples_1kqc.htmC++Demonstrates how to backup or restore a database using snapshot extensions.XMLXMLDemoMS-ITS:samples.chm::/samples_6fj3.htmXMLDemonstrates Microsoft(r) SQL Server(tm) 2000 support for XML.XMLXMLStartupMS-ITS:samples.chm::/samples_0374.htmXMLDemonstrates features that make SQL Server an XML-enabled database server.
New and updated SQL Server programming samples are available from the Microsoft Web site. On the Resources menu, click Code Center.
Note When using the sample programs, ensure that hard-coded values, such as user name and password, are modified as necessary.