Solved

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

Posted on 2008-10-02
4
1,041 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 500 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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.
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

738 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