These are examples of queries you can use to return list values from the SOLIDWORKS 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.
SELECT Date
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.