Solved

DOS Batch variable in isql

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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