Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Syntax for WQL Source Query in SSIS Variable

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL 10 35
Amazon RDS migrate to SQL Server 3 24
SQL Group By Question 4 18
Get rid of the last Last comma and space in a SQL statement. 7 14
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
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 different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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.

809 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