Samples

Samples

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.

ADO Employee ../adosql/adoprg04_9nc9.htm Visual Basic Displays long data types using the Employees table in the Northwind database. ADO Employee MS-ITS:/adosql.chm::/adoprg04_1sa1.htm C++ Displays long data types using the Employees table in the Northwind database. ADO FORXML ../adosql/adoprg04_92gc.htm XML Builds an Active Server Page (ASP) that retrieves result sets into streams. ADO Intro ../adosql/adoprg04_5iw7.htm Visual Basic Connects to and queries a SQL Server database. Also shows error handling. ADO OpenXML ../adosql/adoprg04_15ik.htm XML Builds an Active Server Page (ASP) that maps an XML schema to a relational schema. ADO Xpath ../adosql/adoprg04_21vd.htm XML Builds an Active Server Page (ASP) that performs an xpath query. ADO Web ../adosql/adoprg04_85ym.htm Web Builds Active Server Page (ASP)that interacts with instance of SQL Server. Analysis Services AspAdoComplex ../olapdmpr/prsamples_1rji.htm VBScript Creates and manipulates a query-based cube. Analysis Services AspAdoCubeDoc ../olapdmpr/prsamples_6p7y.htm VBSCript Retrieves and manipulates a cube schema. Analysis Services AspAdoCubeTree ../olapdmpr/prsamples_6p7y.htm VBScript,JScript Retrieves and manipulates a cube schema. Analysis Services AspAdoSimple ../olapdmpr/prsamples_1rji.htm VBScript Creates and manipulates a query-based cube. Analysis Services CppOlapDemo ../olapdmpr/prsamples_1rji.htm C++ Creates and manipulates a query-based cube. Analysis Services VbAdoComplex ../olapdmpr/prsamples_1rji.htm Visual Basic Creates and manipulates a query-based cube. Analysis Services VbAdoCreateCube ../olapdmpr/prsamples_96zy.htm Visual Basic Creates a client-side cube. Analysis Services VbAdoCubeDoc ../olapdmpr/prsamples_6p7y.htm Visual Basic Retrieves and manipulates a cube schema. Analysis Services VbAdoSimple ../olapdmpr/prsamples_1rji.htm Visual Basic Creates and manipulates a query-based cube. Analysis Services VbDsoCreateSmallCube ../olapdmpr/prsamples_63ou.htm Visual Basic Creates and manipulates a complex cube. Analysis Services VbDSOExample ../olapdmpr/prsamples_96zy.htm Visual Basic Creates a server-side cube. Analysis Services VbAdoWriteBack ../olapdmpr/prsamples_63ou.htm Visual Basic Creates and manipulates a complex cube. Analysis Services VbDsoWriteEnableCube ../olapdmpr/prsamples_63ou.htm Visual Basic Creates and manipulates a complex cube. Analysis Services VbMdHTMLdll ../olapdmpr/prsamples_63ou.htm Visual Basic Creates and manipulates a complex cube. DB Library Example8 ../dblibc/dbc_db_csamp_3k6r.htm C++ Shows DB Library support for output parameters in Microsoft SQL Server stored procedures. DB Library Sqlexamp ../dblibc/dbc_db_csamp_8gvn.htm C++ Shows how to handle various data types for consistent output. DB Library Sqltestc ../dblibc/dbc_db_csamp_2tpj.htm C++ Issues a simple SELECT statement and prints the returned result set rows to the console. DB Library Sqltestn ../dblibc/dbc_db_csamp_71pq.htm C++ Connects to a database and executes a SELECT statement from the Microsoft(r) Windows NT(r) graphical user interface. DB Library Textcopy ../dblibc/dbc_db_csamp_67dt.htm C++ Illustrates how to handle Microsoft SQL Server text and image data types from a Microsoft Foundation Class (MFC) console. Desktop Engine Desktop Engine installlation ../distsql/distsql_9zad.htm C++ Installs an instance of the Desktop Engine. DTS CustomTaskNoUI ../dtsprog/dtspsamp_7u3t.htm Active 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. DTS CustomTaskWithUI ../dtsprog/dtspsamp_0dk9.htm Active Template Library (ATL) ATL template for a DTS custom task that supports a custom user interface. DTS CustomTransform ../dtsprog/dtspsamp_9tkd.htm Active Template Library (ATL) ATL template for a DTS custom transformation. DTS DTSActiveScriptTask ../dtsprog/dtspsamp_76p7.htm Visual Basic Runs a VBScript as part of a DTS Task. DTS DTSAppObject ../dtsprog/dtspsamp_91ys.htm Visual Basic Uses DTS application object on the local server. DTS DTSApplicationObject MS-ITS:\dtsprog.chm::/dtspsamp_4a7o.htm Visual Basic Gets information from the DTS Application object. DTS DTSBulkInsertTask ../dtsprog/dtspsamp_14iz.htm Visual Basic Uses DTS to do a Bulk Insert from a flat text file. DTS DTSCopy ../dtsprog/dtspsamp_0k55.htm C++ Copies a single source column of any simple type into a destination column of the same type. DTS DTSCopyDatabase ../dtsprog/dtspsamp_5pnp.htm Visual Basic Uses the DTS TransferObjectsTask object to copy a database. DTS DTSExecProcess ../dtsprog/dtspsamp_9ik3.htm Visual Basic Runs a Win32 application from a DTS task. DTS DTSExecSQLTask ../dtsprog/dtspsamp_2ip7.htm Visual Basic Executes a SQL statement while running a DTS package. DTS DTSExecutePackage ../dtsprog/dtspsamp_6jvp.htm Visual Basic Executes programmatically a DTS package that has been saved to structured storage (i.e. .dts file). DTS DTSexmp1 ../dtsprog/dtspsamp_5wvn.htm Visual Basic Copies data from a source table to a destination table. DTS DTSexmp2 ../dtsprog/dtspsamp_7zcc.htm Visual Basic Copies database to Microsoft Excel spreadsheet and creates pivot table; also creates a DTS package. DTS DTSexmp3 ../dtsprog/dtspsamp_3ur7.htm Visual Basic Creates a package supporting multiple sources and destinations. DTS DTSFTPTask ../dtsprog/dtspsamp_6ai3.htm Visual Basic Uses DTS to copy files external to SQL Server from a source to a destination. DTS DTSPackageInfo ../dtsprog/dtspsamp_5rov.htm Visual Basic Gets information using the DTS Application GetPackageInfos method. DTS DTSStrings ../dtsprog/dtspsamp_47n7.htm C++ Reformats two source columns. DTS DTStask ../dtsprog/dtspsamp_72qz.htm C++ Creates and registers a CreateProcessTask COM object. DTS DTSTransferObjectsTask ../dtsprog/dtspsamp_65yj.htm Visual Basic Uses DTS to transfer various types of SQLServer objects from a pubs database to a pubs2 database. DTS DTSTskGVUpdate ../dtsprog/dtspsamp_12lh.htm C++ Displays and allows the user to update the value of a global variable. DTS DTSTskPropIcon ../dtsprog/dtspsamp_9f3i.htm C++ Displays a message whose text is specified as a custom task property. DTS DTSvbpkg ../dtsprog/dtspsamp_5ns3.htm Visual Basic Builds and executes a DTS package. DTS DTSxform ../dtsprog/dtspsamp_74h1.htm C++ Creates and registers a custom Transformation object. DTS FoodMart2000 ../dtsprog/dtspsamp_7smo.htm Visual Basic Uses the Visual Basic file output from the DTS import/export wizard to convert the FoodMart 2000.mdb database to SQLServer. DTS Packages ../dtsprog/dtspsamp_0f8z.htm C++ Creates and registers a custom Transformation object. DTS Pub2Pubs ../dtsprog/dtspsamp_2m7n.htm Visual Basic Copies the authors table from the 'pubs' database to the 'pubs2' database, while doing some operations on various fields. Embedded SQL Edlib ../esqlforc/ec_6_eex_00_9o36.htm C Uses GET CONNECTION to obtain the DB-Library DBPROCESS connection pointer. Embedded SQL Embedded SQL for C Examples ../esqlforc/ec_6_eex_00_6376.htm C 8 examples using C to connect to a specified instance of MicrosoftSQL Server and execute a series of Embedded SQL statements. Embedded SQL Genchar ../esqlforc/ec_6_eex_00_4uya.htm C Issues a SELECT statement query from the authors table in the pubs database. Embedded SQL Genwin ../esqlforc/ec_6_eex_00_2a7m.htm C Issues a SELECT statement query from the authors table in the pubs database. Extended Stored Procedure xp-dblib ../odssql/ods_6_sam_01_4xia.htm C Uses DB Library to open bound connection to same SQL Server that called the extended stored procedure. Extended Stored Procedure xp-hello ../odssql/ods_6_sam_01_060f.htm C Displays "hellow world" in output row. Extended Stored Procedure xp-ODBC ../odssql/ods_6_sam_01_9jkz.htm C Uses ODBC to open bound connection to same SQL Server that called the extended stored procedure. Extended Stored Procedure xp-param ../odssql/ods_6_sam_01_4yel.htm C Accepts parameters from Transact-SQL script and reports values. MS DTC DB Library ../samples/samp_msdtc_5a79.htm C++ Shows how to use MS-DTC in a C++ program. MS DTC ODBC ../samples/samp_msdtc_5tnp.htm C++ Shows how to use MS-DTC in a C++ program, using ODBC. MS DTC T-SQL ../samples/samp_msdtc_26hx.htm Transact-SQL Shows how to use MS-DTC in a Transact-SQL script. ODBC bcp ../odbcsql/od_odbcsamp_4pm8.htm C++ Uses bulk copy functions with ODBC driver. ODBC Compute ../odbcsql/od_odbcsamp_7yb7.htm C++ Executes SELECT statement, then determines shape of each result set generated. ODBC Loaddata ../odbcsql/od_odbcsamp_74rl.htm C++ Loads data into SQL Server table. ODBC Mfcperf ../odbcsql/od_odbcsamp_7xly.htm C++ Tunes MFC ODBC database classes for performance, and captures and interprets Microsoft SQL Server ODBC driver performance data. ODBC Trans ../odbcsql/od_odbcsamp_8037.htm C++ Uses cursors to enable concurrent data access. OLE Automation Getnpv ../samples/samp_oleauto_04md.htm Visual Basic Retrieves net present value. OLE Automation Loopback (DAO) ../samples/samp_oleauto_7x45.htm Visual Basic Retrieves 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 Automation Loopback (RDO) ../samples/samp_oleauto_5lyd.htm Visual Basic Uses 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 Automation Traverse ../samples/samp_oleauto_5t2d.htm Transact-SQL Traverses an object hierarchy. Replication Deflt_sp ../replprog/rp_replsamp_446q.htm Transact-SQL Builds a custom stored procedure resolver. Replication Distsamp ../replprog/rp_replsamp_2pf2.htm C++ Shows how to include the SQL Merge and SQL Distribution controls in a custom application. Replication Repldts ../replprog/rp_replsamp_3l0j.htm Visual Basic Creates a transformation subscription. Replication Replsamp ../replprog/rp_replsamp_5uwe.htm HTML Shows how to include the SQL Merge and SQL Distribution controls in a custom application. Replication Replsamp.vbp ../replprog/rp_replsamp_7yr2.htm Visual Basic Shows how to include the SQL Merge and SQL Distribution controls in a custom application. Replication Samppub ../replprog/rp_replsamp_2mr3.htm Transact-SQL Configures a third-party publication and distributor. Replication Subspres ../replprog/rp_replsamp_6p5x.htm C++ Builds a custom stored procedure resolver that executes the stored procedure at the Subscriber. Replication xp_enumntusers ../replprog/rp_replsamp_3rsj.htm C++ Generates multiple merge dynamic snapshot jobs. SQL-DMO AxSQLDMOCtl ../sqldmo/dmoref_ex01_3uy4.htm Visual Basic Creates a UserControl. SQL-DMO BackRestEvents ../sqldmo/dmoref_ex01_0kix.htm Visual Basic Backs up and restores a database. SQL-DMO BackRestEvents ../sqldmo/dmoref_ex01_01gp.htm C++ Backs up and restores a database. SQL-DMO BackupDevice ../sqldmo/dmoref_ex01_325h.htm Visual Basic Uses BackupDevice object to add and remove a backup device. SQL-DMO CreateDatabase ../sqldmo/dmoref_ex01_0bs5.htm Visual Basic Creates a database. SQL-DMO CreateTable ../sqldmo/dmoref_ex01_5w11.htm Visual Basic Uses SQL-DMO objects to create and alter tables. SQL-DMO DMOExplorer ../sqldmo/dmoref_ex01_53ci.htm Visual Basic Walks the DMO object model and shows the values in it. SQL-DMO Dmoping ../sqldmo/dmoref_ex01_82pl.htm C++ Determines version of SQL Server instance. SQL-DMO Enums ../sqldmo/dmoref_ex01_8roz.htm Visual Basic Uses SQL Server enumeration methods and recordsets. SQL-DMO Explore ../sqldmo/dmoref_ex01_5a3p.htm Visual Basic Displays contents of collections and properties of objects in SQL-DMO object tree. SQL-DMO Idxtest ../sqldmo/dmoref_ex01_3cc4.htm Visual Basic Tests optimization strategies for stored procedures and views. SQL-DMO Login ../sqldmo/dmoref_ex01_0b72.htm Visual Basic Locates available SQL Servers and logs in to them. SQL-DMO Registry ../sqldmo/dmoref_ex01_7gxl.htm Visual Basic Finds registry information about a specified SQL Server. SQL-DMO Service ../sqldmo/dmoref_ex01_04yt.htm Visual Basic Checks status of, starts, and stops the service. SQL-DMO Smartptr ../sqldmo/dmoref_ex01_07oy.htm C++ Uses Microsoft Visual C++ features to optimize size of program and speed of development. SQL-DMO Soc ../sqldmo/dmoref_ex01_40tf.htm C Shows how to use C for SQL-DMO development. SQL-DMO Socpp ../sqldmo/dmoref_ex01_74kw.htm C++ Shows how to use C++ for SQl-DMO development. SQL-DMO SQLScripts ../sqldmo/dmoref_ex01_13sj.htm Visual Basic Shows how to generat SQL scripts to regenerate SQLServer objects. SQL-DMO VerifyBackup ../sqldmo/dmoref_ex01_3t80.htm Visual Basic Finds backup devices and verifies backup set. SQL-NS Dbprop ../sqlns/ns_samp_6x2a.htm C++ Displays Properties dialog for Pubs database. SQL-NS Dumptree ../sqlns/ns_samp_5t7p.htm C++ Dumps all objects in the SQL namespace tree. SQL-NS Browse ../sqlns/ns_samp_2h82.htm Visual Basic Creates browser for viewing and manipulating SQL namespace. SQL-NS Dbprop ../sqlns/ns_samp_85gj.htm Visual Basic Displays Properties dialog for Pubs database. User Defined Functions CustNamesInRegion ../samples/samples_1far.htm Transact-SQL Creates an in-line user-defined function in the Northwind database to view customer information for specific regions from the Customers table. User Defined Functions FindReports ../samples/samples_1far.htm Transact-SQL Queries the Employees table in the Northwind database and shows all direct and indirect reports. User Defined Functions LargeFreight ../samples/samples_1far.htm Transact-SQL Creates 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 Functions MyDate ../samples/samples_1far.htm Transact-SQL Changes the format in which the date is returned Utilities Bii ../samples/samples_2isp.htm Executable utiiity Mimics the bcp utility, but adds additional functinality. Utilities Pbalance ../samples/samples_9h9h.htm C++ Displays process information for instances of Microsoft(r) SQL Server(tm) 2000 running on a local computer,and manages process priorities. Virtual Backup Device Mprocess ../samples/samples_2p0z.htm C++ Demonstrates a multiple stream Backup or Restore, in which each stream is handled by a secondary process.. Virtual Backup Device Mthread ../samples/samples_0b38.htm C++ Demonstrates a multiple stream Backup or Restore from a single process. Virtual Backup Device Osimple ../samples/samples_2j51.htm C++ Demonstrates how to backup or restore a database across an ODBC connection. Virtual Backup Device Simple ../samples/samples_4rfp.htm C++ Demonstrates how to backup or restore a database. Virtual Backup Device Snapshot ../samples/samples_1kqc.htm C++ Demonstrates how to backup or restore a database using snapshot extensions. XML XMLDemo ../samples/samples_6fj3.htm XML Demonstrates Microsoft(r) SQL Server(tm) 2000 support for XML. XML XMLStartup ../samples/samples_0374.htm XML Demonstrates 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.

/SELECT>

 

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.