Monday, March 26, 2012

How to create database on remote machine using osql

Hi All,
I am using OSQL to create database.
When I am using it to create the database localy it works great when I
use the -s switch (target manchine) the call ended successfuly only the
database is created om my PC and not on the remote one.
Does anyone know why?
Thanks in advance Oren
What is your call, that should work also remotely ?
HTH, Jens Suessmeyer.
|||Do you have proper permissions on the remote machine? Can you post the oSql
call?
Andrew J. Kelly SQL MVP
<orencs@.gmail.com> wrote in message
news:1139142162.951389.181080@.o13g2000cwo.googlegr oups.com...
> Hi All,
> I am using OSQL to create database.
> When I am using it to create the database localy it works great when I
> use the -s switch (target manchine) the call ended successfuly only the
> database is created om my PC and not on the remote one.
> Does anyone know why?
>
> Thanks in advance Oren
>
|||I'm not sure if it's a typo but the way to run a command on a different
server is to use the -S parameter. -s sets the column separator which is
probably not what you want.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
<orencs@.gmail.com> wrote in message
news:1139142162.951389.181080@.o13g2000cwo.googlegr oups.com...
> Hi All,
> I am using OSQL to create database.
> When I am using it to create the database localy it works great when I
> use the -s switch (target manchine) the call ended successfuly only the
> database is created om my PC and not on the remote one.
> Does anyone know why?
>
> Thanks in advance Oren
>
|||Sorry, my mistake for not providing enough information.
I am running the following:
A Batch file
osql -U sa -P poqi -i "1install.sql" -o "install.res"
The install.sql file looks like this:
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name =
N'MyDB')
DROP DATABASE [MyDB]
GO
CREATE DATABASE [MyDB]
GO
use [MyDB]
GO
...Then I create the tables SP etc...
The above works great when I want to create the database on my
computer.
My problem is that I need to run the scripts in PC A and install the
database on PC B.
The batch and sql file are in PC A.
I don't know how to do that.
I have tried the -s switch for the OSQL command.
I have change the batch file like this:
osql -S 100.100.100.11 -U sa -P poqi -i "1install.sql" -o
"install.res"
100.100.100.11 - is the IP of PC B.
I don't receive any error.
The install.res file indicate that everything went well and in fact it
did only the OSQL command disregard the -s switch and create the DB on
PC A.
Any ideas?
Roger Wolter[MSFT] wrote:[vbcol=seagreen]
> I'm not sure if it's a typo but the way to run a command on a different
> server is to use the -S parameter. -s sets the column separator which is
> probably not what you want.
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
> <orencs@.gmail.com> wrote in message
> news:1139142162.951389.181080@.o13g2000cwo.googlegr oups.com...
|||Are you sure that 100.100.100.11 is in fact the remote computer and not the
local one? You might want to start with a simpler and safer test script
until you know it is talking to the right server. Maybe just select
@.@.SERVERNAME?
Andrew J. Kelly SQL MVP
<orencs@.gmail.com> wrote in message
news:1139294796.871063.293590@.f14g2000cwb.googlegr oups.com...
> Sorry, my mistake for not providing enough information.
> I am running the following:
> A Batch file
> osql -U sa -P poqi -i "1install.sql" -o "install.res"
>
> The install.sql file looks like this:
> IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name =
> N'MyDB')
> DROP DATABASE [MyDB]
> GO
> CREATE DATABASE [MyDB]
> GO
> use [MyDB]
> GO
> ...Then I create the tables SP etc...
> The above works great when I want to create the database on my
> computer.
> My problem is that I need to run the scripts in PC A and install the
> database on PC B.
> The batch and sql file are in PC A.
> I don't know how to do that.
> I have tried the -s switch for the OSQL command.
> I have change the batch file like this:
> osql -S 100.100.100.11 -U sa -P poqi -i "1install.sql" -o
> "install.res"
> 100.100.100.11 - is the IP of PC B.
> I don't receive any error.
> The install.res file indicate that everything went well and in fact it
> did only the OSQL command disregard the -s switch and create the DB on
> PC A.
> Any ideas?
>
>
>
>
>
> Roger Wolter[MSFT] wrote:
>
|||HI Andrew
yes I am sure this is the correct server IP.
It looks like the -s swtich does not work
Oren.
|||I don't know of any bugs with the -S. I (and many others) have been using
this for years without a problem like this that I know of. Is there any
chance that EM is pointing to the wrong machine? Maybe oSql is creating it
on the correct machine and EM is pointing to that one when you think it is
pointing to the other? If not I am not sure what to tell you as the -S
should work. Again as Roger stated it must be a Capital S. You just listed
it as a lower case s.
Andrew J. Kelly SQL MVP
<orencs@.gmail.com> wrote in message
news:1139401703.086471.286520@.g44g2000cwa.googlegr oups.com...
> HI Andrew
> yes I am sure this is the correct server IP.
> It looks like the -s swtich does not work
> Oren.
>

No comments:

Post a Comment