Solved

Syntax for WQL Source Query in SSIS Variable

Posted on 2011-03-08
2
1,546 Views
Last Modified: 2013-11-10
I've got an SSIS package that watches for XML files in a specific folder.  The package works when I enter the WQL Query directly into the task editor, but I can't get it to work using the same query as a variable.  This must be a syntax issue but I haven't been able to find any examples of creating this kind of query in a variable.  The query I'm typing in directly is:

Select * From __InstanceCreationEvent Within 10 Where TargetInstance ISA 'Cim_DataFile' And TargetInstance.Drive = 'C:' And TargetInstance.Path = '\\Data\\' And TargetInstance.Extension = 'xml'

When I tried to set this same query as the expression of a variable and evaluated the expression, I got an error like "...unrecognized token: select".  So then i enclosed the whole string in double quotes.  It evaluated okay, but when I ran the package in Design mode I got the error "unparseable query."  

The scope of the variable is the package. I have 'evaluate as expression' set to True.  The data type of the variable is String.  If i enter the query without the quotes into the WMI Tester it succeeds and if I enter the query with the quotes i get the same error = unparseable query.  

My ultimate goal is to replace the 'C:' and the '\\Data\\' with variables that are set per configuration.  I tried that first and now I'm stepping back to get any query to work as a variable.  

Can someone help me understand how this WQL query needs to look when the WQL Source Query Type is Variable?
0
Comment
Question by:sanw2020
2 Comments
 
LVL 16

Accepted Solution

by:
vdr1620 earned 500 total points
ID: 35087457
Never tried WQL query this is how i would have used it, if using an expression for a SQL query. I would assume that the same will work as WQL

declare 3 variables Ex: Drive with value 'C:'  (including quotes) and Path with value - '\\Data\\' (include quotes) then in the 3rd variable
use an Expression as below

"Select * From __InstanceCreationEvent Within 10 Where TargetInstance ISA 'Cim_DataFile' And TargetInstance.Drive = "+ @[User::Drive] +" And TargetInstance.Path = "+@[User::Path]+"  And TargetInstance.Extension = 'xml' "

when evaluated it show the query as you have posted.. use this variable in the WQL source.. also, you will be able to set the values of the 1st two variables using Configurations in this way


Hope that helps.. Let me know if you see any problems with the query
0
 

Author Closing Comment

by:sanw2020
ID: 35087683
Thanks so much!  I know it was probably a basic question but I was stuck just the same.  Now I can move forward.  Thank you!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Server 2012 r2 - Sum totals 2 23
Mysql Left Join Case 10 48
SQL - Copy data from one database to another 6 19
error in my cursor 5 25
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question