Solved

Syntax for WQL Source Query in SSIS Variable

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

771 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

10 Experts available now in Live!

Get 1:1 Help Now