Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to give variables in command line in sql server agent 2005

Posted on 2008-10-02
4
Medium Priority
?
1,054 Views
Last Modified: 2013-11-10
I have the following syntax example
select * from Products where supplierID=? and categoryid=?(i used this syntax in SSIS)
I created SSIS variables @suppID and @catID
I want to execute above sql statement as a JOB by using SQL server Agent
How can I pass the varriable values through sql server agent though command line
0
Comment
Question by:coventri
[X]
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
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:randy_knight
ID: 22631215
You need to use the /SET option for DTEXEC.EXE.  It can be used to speciy a value for any property, not just variables.  

Also, an easy way to generate DTEXEC statements is to use the DTEXECUI utility (same as run pacakge in SSMS) and set everthing, then click on CommandLine.  Append what is generated to DTEXEC and you're good to go.
0
 
LVL 1

Author Comment

by:coventri
ID: 22641450
Hi Randy,
In sql agent step  in Command line option i changed the restore original option to edit the command lineoption manually.Then i enter the following code
/FILE "C:\Users\prithvi\Documents\Visual Studio 2005\Projects\extracting and archiving file\extracting and archiving file\Package.dtsx"  /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /SET"\Package.Variables[User::categorytid].Value";1/SET"\Package.Variables[User::supplierid].Value";1 /REPORTING E

It was giving error like
Option "/SET\Package.Variables[User::categorytid].Value;1" is not valid.  The command line parameters are invalid.  The step failed.
Thanks for ur help
0
 
LVL 1

Author Comment

by:coventri
ID: 22641477
Executed as user: PRITHVI-PC\SYSTEM. Microsoft (R) SQL Server Execute Package Utility  Version 9.00.3042.00 for 32-bit  Copyright (C) Microsoft Corp 1984-2005. All rights reserved.    Argument "OFF/SET\Package.Variables[User::supplierid].Value;1/SET\Package.Variables[User::categoryid].Value;1" for option "checkpointing" is not valid.  The command line parameters are invalid.  The step failed.
0
 
LVL 4

Accepted Solution

by:
randy_knight earned 1500 total points
ID: 22641682
did you try generating your command line using the Execute Package utility?  Thtat's what I always do to get it right.  Open up DTEXECUI from SSMS, then set all your options including variables.  Then click on command line and it will give you the command line you need.  Copy that and paste it into the SQL Agent step.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

596 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