Solved

DOS Batch variable in isql

Posted on 2000-04-27
1
1,600 Views
Last Modified: 2012-05-04
Is it possible to pass a DOS batch variable like a database name into an isql script. For example could I pass my variable "%1" into the create database command
(isql> create database "%1"....) to automatcially create a database name as specified in the batch calling the isql command?  How??
0
Comment
Question by:wcampb_ell
[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
1 Comment
 
LVL 1

Accepted Solution

by:
albertsp earned 50 total points
ID: 2758718
Try this the following batfile. You should modify it in the create database section. I know nothing about your devices. Probably pass thos with a variable too.

Succes, Albert

----------------------------------------------------------------------------------------------

@echo off
:: -------------------------------------------------------------------------
:: Shows sp_spaceused output for the given database
::
:: Parameters: 1: SQL Server name
::             2: Database name
::             3: Password
:: -------------------------------------------------------------------------
if  X%1X == XX goto USAGE
if  X%2X == XX goto USAGE
if  X%3X == XX goto USAGE

set SERVER=%1
set DBNAME=%2
set PASSWD=%3

set TBLSQL=CR_DB.SQL
set TBLOUT=CR_DB.OUT

>  %TBLSQL% echo use  master
>> %TBLSQL% echo set  nocount on
>> %TBLSQL% echo go
>> %TBLSQL% echo create database %DBNAME%
>> %TBLSQL% echo on datdev.dat = ...
>> %TBLSQL% echo log on logdev.dat = ...
>> %TBLSQL% echo go

c:\sybase\bin\isql -Usa -P%PASSWD% -S%SERVER% -i %TBLSQL% -o %TBLOUT%

::if exist %TBLSQL% del %TBLSQL%
set SERVER=
set DBNAME=
set TBLSQL=
set TBLOUT=

goto END

:USAGE
echo ---------------------------------------------------------------------------
echo Usage: cr_tab servername, dbname,Password
echo Creates database on given server
echo ---------------------------------------------------------------------------
:END

-----------------------------------------------------------------------------------------------
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Make the most of your online learning experience.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

690 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