Hide Table of Contents

SQL Query Examples

These are examples of queries you can use to return list values from the Enterprise PDM database.

List All Unique Values Stored in a Specified Variable

This example lists values by replacing the variable name.

Select distinct Vv.ValueCache
 From VariableValue Vv
 Where Vv.VariableID =  (     select variableid
                    from variable
                    where Variablename like 'Project number')
       And Vv.ValueCache != ''
 order by Vv.ValueCache ASC

List All Project Folders Stored Under a Specified Folder

This example lists folders by replacing the folder path.

Select P.Name
 From Projects P, ProjectTree Pt, Projects P2
 where P.ProjectID > 1 And
            P2.Path Like '\Projects\' And
            P2.ProjectID = Pt.ProjectID And
            P.ProjectID = Pt.ChildProject
 Order By P.Name Asc

Retrieve Values from an ODBC Source

Using this method, you can get values from an ODBC source, such as an Excel spreadsheet. However, it is recommended that you use the linked server option. See Retrieving SQL Values from a Linked Server Source.

 FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
   'Data Source="c:\Book1.xls";
     User ID=Admin;Password=;Extended properties=Excel 8.0')...Sheet1$ 
In this example:
  • The Excel file must be accessible by the SQL server (can be UNC path).
  • Date is the column name.
  • Sheet1 is the sheet name.
  • The server connection information should be to the local SQL server. For example, you can use the vault database name.

Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   SQL Query Examples
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: SOLIDWORKS PDM 2012 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.