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.
ADOEmployee../adosql/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.ADOFORXML../adosql/adoprg04_92gc.htmXMLBuilds an Active Server Page (ASP) that retrieves result sets into streams.ADOIntro../adosql/adoprg04_5iw7.htmVisual BasicConnects to and queries a SQL Server database. Also shows error handling.ADOOpenXML../adosql/adoprg04_15ik.htmXMLBuilds an Active Server Page (ASP) that maps an XML schema to a relational schema.ADOXpath../adosql/adoprg04_21vd.htmXMLBuilds an Active Server Page (ASP) that performs an xpath query.ADOWeb../adosql/adoprg04_85ym.htmWebBuilds Active Server Page (ASP)that interacts with instance of SQL Server.Analysis ServicesAspAdoComplex../olapdmpr/prsamples_1rji.htmVBScriptCreates and manipulates a query-based cube.Analysis ServicesAspAdoCubeDoc../olapdmpr/prsamples_6p7y.htmVBSCriptRetrieves and manipulates a cube schema.Analysis ServicesAspAdoCubeTree../olapdmpr/prsamples_6p7y.htmVBScript,JScriptRetrieves and manipulates a cube schema.Analysis ServicesAspAdoSimple../olapdmpr/prsamples_1rji.htmVBScriptCreates and manipulates a query-based cube.Analysis ServicesCppOlapDemo../olapdmpr/prsamples_1rji.htmC++Creates and manipulates a query-based cube.Analysis ServicesVbAdoComplex../olapdmpr/prsamples_1rji.htmVisual BasicCreates and manipulates a query-based cube.Analysis ServicesVbAdoCreateCube../olapdmpr/prsamples_96zy.htmVisual BasicCreates a client-side cube.Analysis ServicesVbAdoCubeDoc../olapdmpr/prsamples_6p7y.htmVisual BasicRetrieves and manipulates a cube schema.Analysis ServicesVbAdoSimple../olapdmpr/prsamples_1rji.htmVisual BasicCreates and manipulates a query-based cube.Analysis ServicesVbDsoCreateSmallCube../olapdmpr/prsamples_63ou.htmVisual BasicCreates and manipulates a complex cube.Analysis ServicesVbDSOExample../olapdmpr/prsamples_96zy.htmVisual BasicCreates a server-side cube.Analysis ServicesVbAdoWriteBack../olapdmpr/prsamples_63ou.htmVisual BasicCreates and manipulates a complex cube.Analysis ServicesVbDsoWriteEnableCube../olapdmpr/prsamples_63ou.htmVisual BasicCreates and manipulates a complex cube.Analysis ServicesVbMdHTMLdll../olapdmpr/prsamples_63ou.htmVisual BasicCreates and manipulates a complex cube.DB LibraryExample8../dblibc/dbc_db_csamp_3k6r.htmC++Shows DB Library support for output parameters in Microsoft SQL Server stored procedures.DB LibrarySqlexamp../dblibc/dbc_db_csamp_8gvn.htmC++Shows how to handle various data types for consistent output.DB LibrarySqltestc../dblibc/dbc_db_csamp_2tpj.htmC++Issues a simple SELECT statement and prints the returned result set rows to the console.DB LibrarySqltestn../dblibc/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 LibraryTextcopy../dblibc/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 installlation../distsql/distsql_9zad.htmC++Installs an instance of the Desktop Engine.DTSCustomTaskNoUI../dtsprog/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.DTSCustomTaskWithUI../dtsprog/dtspsamp_0dk9.htmActive Template Library (ATL)ATL template for a DTS custom task that supports a custom user interface.DTSCustomTransform../dtsprog/dtspsamp_9tkd.htmActive Template Library (ATL)ATL template for a DTS custom transformation.DTSDTSActiveScriptTask../dtsprog/dtspsamp_76p7.htmVisual BasicRuns a VBScript as part of a DTS Task.DTSDTSAppObject../dtsprog/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.DTSDTSBulkInsertTask../dtsprog/dtspsamp_14iz.htmVisual BasicUses DTS to do a Bulk Insert from a flat text file.DTSDTSCopy../dtsprog/dtspsamp_0k55.htmC++Copies a single source column of any simple type into a destination column of the same type.DTSDTSCopyDatabase../dtsprog/dtspsamp_5pnp.htmVisual BasicUses the DTS TransferObjectsTask object to copy a database.DTSDTSExecProcess../dtsprog/dtspsamp_9ik3.htmVisual BasicRuns a Win32 application from a DTS task.DTSDTSExecSQLTask../dtsprog/dtspsamp_2ip7.htmVisual BasicExecutes a SQL statement while running a DTS package.DTSDTSExecutePackage../dtsprog/dtspsamp_6jvp.htmVisual BasicExecutes programmatically a DTS package that has been saved to structured storage (i.e. .dts file).DTSDTSexmp1../dtsprog/dtspsamp_5wvn.htmVisual BasicCopies data from a source table to a destination table.DTSDTSexmp2../dtsprog/dtspsamp_7zcc.htmVisual BasicCopies database to Microsoft Excel spreadsheet and creates pivot table; also creates a DTS package.DTSDTSexmp3../dtsprog/dtspsamp_3ur7.htmVisual BasicCreates a package supporting multiple sources and destinations.DTSDTSFTPTask../dtsprog/dtspsamp_6ai3.htmVisual BasicUses DTS to copy files external to SQL Server from a source to a destination.DTSDTSPackageInfo../dtsprog/dtspsamp_5rov.htmVisual BasicGets information using the DTS Application GetPackageInfos method.DTSDTSStrings../dtsprog/dtspsamp_47n7.htmC++Reformats two source columns.DTSDTStask../dtsprog/dtspsamp_72qz.htmC++Creates and registers a CreateProcessTask COM object.DTSDTSTransferObjectsTask../dtsprog/dtspsamp_65yj.htmVisual BasicUses DTS to transfer various types of SQLServer objects from a pubs database to a pubs2 database.DTSDTSTskGVUpdate../dtsprog/dtspsamp_12lh.htmC++Displays and allows the user to update the value of a global variable.DTSDTSTskPropIcon../dtsprog/dtspsamp_9f3i.htmC++Displays a message whose text is specified as a custom task property.DTSDTSvbpkg../dtsprog/dtspsamp_5ns3.htmVisual BasicBuilds and executes a DTS package.DTSDTSxform../dtsprog/dtspsamp_74h1.htmC++Creates and registers a custom Transformation object.DTSFoodMart2000../dtsprog/dtspsamp_7smo.htmVisual BasicUses the Visual Basic file output from the DTS import/export wizard to convert the FoodMart 2000.mdb database to SQLServer.DTSPackages../dtsprog/dtspsamp_0f8z.htmC++Creates and registers a custom Transformation object.DTSPub2Pubs../dtsprog/dtspsamp_2m7n.htmVisual BasicCopies the authors table from the 'pubs' database to the 'pubs2' database, while doing some operations on various fields.Embedded SQLEdlib../esqlforc/ec_6_eex_00_9o36.htmCUses GET CONNECTION to obtain the DB-Library DBPROCESS connection pointer.Embedded SQLEmbedded SQL for C Examples../esqlforc/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 SQLGenchar../esqlforc/ec_6_eex_00_4uya.htmCIssues a SELECT statement query from the authors table in the pubs database.Embedded SQLGenwin../esqlforc/ec_6_eex_00_2a7m.htmCIssues a SELECT statement query from the authors table in the pubs database.Extended Stored Procedurexp-dblib../odssql/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-hello../odssql/ods_6_sam_01_060f.htmCDisplays "hellow world" in output row.Extended Stored Procedurexp-ODBC../odssql/ods_6_sam_01_9jkz.htmCUses ODBC to open bound connection to same SQL Server that called the extended stored procedure.Extended Stored Procedurexp-param../odssql/ods_6_sam_01_4yel.htmCAccepts parameters from Transact-SQL script and reports values.MS DTCDB Library../samples/samp_msdtc_5a79.htmC++Shows how to use MS-DTC in a C++ program.MS DTCODBC../samples/samp_msdtc_5tnp.htmC++Shows how to use MS-DTC in a C++ program, using ODBC.MS DTCT-SQL../samples/samp_msdtc_26hx.htmTransact-SQLShows how to use MS-DTC in a Transact-SQL script.ODBCbcp../odbcsql/od_odbcsamp_4pm8.htmC++Uses bulk copy functions with ODBC driver.ODBCCompute../odbcsql/od_odbcsamp_7yb7.htmC++Executes SELECT statement, then determines shape of each result set generated.ODBCLoaddata../odbcsql/od_odbcsamp_74rl.htmC++Loads data into SQL Server table.ODBCMfcperf../odbcsql/od_odbcsamp_7xly.htmC++Tunes MFC ODBC database classes for performance, and captures and interprets Microsoft SQL Server ODBC driver performance data.ODBCTrans../odbcsql/od_odbcsamp_8037.htmC++Uses cursors to enable concurrent data access.OLE AutomationGetnpv../samples/samp_oleauto_04md.htmVisual BasicRetrieves net present value.OLE AutomationLoopback (DAO)../samples/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)../samples/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 AutomationTraverse../samples/samp_oleauto_5t2d.htmTransact-SQLTraverses an object hierarchy.ReplicationDeflt_sp../replprog/rp_replsamp_446q.htmTransact-SQLBuilds a custom stored procedure resolver.ReplicationDistsamp../replprog/rp_replsamp_2pf2.htmC++Shows how to include the SQL Merge and SQL Distribution controls in a custom application.ReplicationRepldts../replprog/rp_replsamp_3l0j.htmVisual BasicCreates a transformation subscription.ReplicationReplsamp../replprog/rp_replsamp_5uwe.htmHTMLShows how to include the SQL Merge and SQL Distribution controls in a custom application.ReplicationReplsamp.vbp../replprog/rp_replsamp_7yr2.htmVisual BasicShows how to include the SQL Merge and SQL Distribution controls in a custom application.ReplicationSamppub../replprog/rp_replsamp_2mr3.htmTransact-SQLConfigures a third-party publication and distributor.ReplicationSubspres../replprog/rp_replsamp_6p5x.htmC++Builds a custom stored procedure resolver that executes the stored procedure at the Subscriber.Replicationxp_enumntusers../replprog/rp_replsamp_3rsj.htmC++Generates multiple merge dynamic snapshot jobs.SQL-DMOAxSQLDMOCtl../sqldmo/dmoref_ex01_3uy4.htmVisual BasicCreates a UserControl.SQL-DMOBackRestEvents../sqldmo/dmoref_ex01_0kix.htmVisual BasicBacks up and restores a database.SQL-DMOBackRestEvents../sqldmo/dmoref_ex01_01gp.htmC++Backs up and restores a database.SQL-DMOBackupDevice../sqldmo/dmoref_ex01_325h.htmVisual BasicUses BackupDevice object to add and remove a backup device.SQL-DMOCreateDatabase../sqldmo/dmoref_ex01_0bs5.htmVisual BasicCreates a database.SQL-DMOCreateTable../sqldmo/dmoref_ex01_5w11.htmVisual BasicUses SQL-DMO objects to create and alter tables.SQL-DMODMOExplorer../sqldmo/dmoref_ex01_53ci.htmVisual BasicWalks the DMO object model and shows the values in it.SQL-DMODmoping../sqldmo/dmoref_ex01_82pl.htmC++Determines version of SQL Server instance.SQL-DMOEnums../sqldmo/dmoref_ex01_8roz.htmVisual BasicUses SQL Server enumeration methods and recordsets.SQL-DMOExplore../sqldmo/dmoref_ex01_5a3p.htmVisual BasicDisplays contents of collections and properties of objects in SQL-DMO object tree.SQL-DMOIdxtest../sqldmo/dmoref_ex01_3cc4.htmVisual BasicTests optimization strategies for stored procedures and views.SQL-DMOLogin../sqldmo/dmoref_ex01_0b72.htmVisual BasicLocates available SQL Servers and logs in to them.SQL-DMORegistry../sqldmo/dmoref_ex01_7gxl.htmVisual BasicFinds registry information about a specified SQL Server.SQL-DMOService../sqldmo/dmoref_ex01_04yt.htmVisual BasicChecks status of, starts, and stops the service.SQL-DMOSmartptr../sqldmo/dmoref_ex01_07oy.htmC++Uses Microsoft Visual C++ features to optimize size of program and speed of development.SQL-DMOSoc../sqldmo/dmoref_ex01_40tf.htmCShows how to use C for SQL-DMO development.SQL-DMOSocpp../sqldmo/dmoref_ex01_74kw.htmC++Shows how to use C++ for SQl-DMO development.SQL-DMOSQLScripts../sqldmo/dmoref_ex01_13sj.htmVisual BasicShows how to generat SQL scripts to regenerate SQLServer objects.SQL-DMOVerifyBackup../sqldmo/dmoref_ex01_3t80.htmVisual BasicFinds backup devices and verifies backup set.SQL-NSDbprop../sqlns/ns_samp_6x2a.htmC++Displays Properties dialog for Pubs database.SQL-NSDumptree../sqlns/ns_samp_5t7p.htmC++Dumps all objects in the SQL namespace tree.SQL-NSBrowse../sqlns/ns_samp_2h82.htmVisual BasicCreates browser for viewing and manipulating SQL namespace.SQL-NSDbprop../sqlns/ns_samp_85gj.htmVisual BasicDisplays Properties dialog for Pubs database.User Defined FunctionsCustNamesInRegion../samples/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 FunctionsFindReports../samples/samples_1far.htmTransact-SQLQueries the Employees table in the Northwind database and shows all direct and indirect reports.User Defined FunctionsLargeFreight../samples/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 FunctionsMyDate../samples/samples_1far.htmTransact-SQLChanges the format in which the date is returnedUtilitiesBii../samples/samples_2isp.htmExecutable utiiityMimics the bcp utility, but adds additional functinality.UtilitiesPbalance../samples/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 DeviceMprocess../samples/samples_2p0z.htmC++Demonstrates a multiple stream Backup or Restore, in which each stream is handled by a secondary process..Virtual Backup DeviceMthread../samples/samples_0b38.htmC++Demonstrates a multiple stream Backup or Restore from a single process.Virtual Backup DeviceOsimple../samples/samples_2j51.htmC++Demonstrates how to backup or restore a database across an ODBC connection.Virtual Backup DeviceSimple../samples/samples_4rfp.htmC++Demonstrates how to backup or restore a database.Virtual Backup DeviceSnapshot../samples/samples_1kqc.htmC++Demonstrates how to backup or restore a database using snapshot extensions.XMLXMLDemo../samples/samples_6fj3.htmXMLDemonstrates Microsoft(r) SQL Server(tm) 2000 support for XML.XMLXMLStartup../samples/samples_0374.htmXMLDemonstrates features that make SQL Server an XML-enabled database server.
Technology
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.