Solved

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

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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

719 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