Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

839 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