Solved

DOS Batch variable in isql

Posted on 2000-04-27
1
1,590 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Advantage DB snapshots, replication or mirroring 2 417
SyBase SQL DataTime Format 6 292
sql statement error 18 75
sybase 3 37
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
An analysis of the phishing scam that has been affecting Google users, along with steps to take for protection, as well as what to do if you receive one of the emails.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

23 Experts available now in Live!

Get 1:1 Help Now