Solved

Syntax for WQL Source Query in SSIS Variable

Posted on 2011-03-08
2
1,540 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

896 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now