Solved

Syntax for WQL Source Query in SSIS Variable

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

733 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