August 15, 2008 at 7:10 am
I created a stored procedure that asks the user for two variables before it runs, a month and a year. The stored procedure has already been tested and runs fine. I have created a batch file that will run the stored procedure but I dont know how to get the batch file to ask for user input and then submit that input into the stored procedures two variables. Can anybody help me with this?
August 15, 2008 at 7:22 am
Not sure what you mean by a batch file. Most .BAT files (which is what I think of when I think of a batch file), operate mostly without human intervention, and don't ask for input variables. Or are you talking about something else?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
August 15, 2008 at 9:00 am
im trying to create a bat file that will ask for user input for two variables that my stored procedure needs to run. This is what I have so far
: Run on dev
@ECHO OFF
set /p USERMONTH = Enter MONTH FOR RECORDS TO BE DELETED
set /p USERYEAR = ENTER YEAR FOR RECORDS TO BE DELETED
osql -Dg1dbdev -SGPATLQQ01 -dGERS EXEC BackupReportingTables @USERMONTH = MONTH @USERYEAR = YEAR
my bat file is not working however and i have been trying to do research on how to do this all day long. The stored procedure itself works just fine
August 15, 2008 at 9:02 am
here is the corrected code, i realized my variables had different names
: Run on dev
@ECHO OFF
set /p USERMONTH = Enter MONTH FOR RECORDS TO BE DELETED
set /p USERYEAR = ENTER YEAR FOR RECORDS TO BE DELETED
osql -Dg1dbdev -SGPATLQQ01 -dGERS EXEC BackupReportingTables @USERMONTH = USERMONTH @USERYEAR = USERYEAR
August 15, 2008 at 2:10 pm
Hi,
you need to delimit your parameters with the percent sign.
Example:
: Run on dev
@ECHO OFF
set /p dbname=Enter dbname
osql -E -dmaster -Q "EXEC sp_helpdb @dbname = '%dbname%'"
PAUSE
Edit: Provided better example
Best Regards,
Chris Büttner
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy