Solved

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

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now