cancel
Showing results for 
Search instead for 
Did you mean: 

Query to Start and Connect Databse on another computer

Former Member
0 Kudos

Hi,

I am trying to start a database on a network location giving path like \\machine-name\mydb\sample.db . START DATABASE sql is not able to start a DB present on another machine or network share.

How can I achieve this ?.

Any help in this regard would be highly appreciated.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

chris_keating
Advisor
Advisor
0 Kudos

This is certainly not a recommended setup. You will generally want the database file and the engine executable running from the same physical machine. There are some network attached storage options that are suitable.

I suspect that the problem you are having is related to the slashes. If you double up the '\'s as in

start database '\\\\machine-name\\mydb\\sample.db'

that should allow you to start the database.

But again, this is not recommended as there is a performance cost to this setup and you have to ensure that the network infrastructure guarantees the write order during I/O otherwise the database can become corrupted.

Why do you want to host the database on a network share?

Former Member
0 Kudos

Thanks for the reply Chris.

Indeed you got it right, it's a network attached storage that I am talking about, so no worries about performance. Even if is not recommended, but for small sized database files this would not hurt for querying small data sets.

About the slashes, of course this is something tricky enough to misguide you, but in my case I have confirmed that I am not making any such mistake while referring .db file.

Apparently START DATABASE call is failing, saying unable to find the db.

Be assured that there is any 'Rights/Permissions' related issue that exists.

Lets see if someone already have done this through SQL Query/SP can come up with any possible solution.

Thanks.

chris_keating
Advisor
Advisor
0 Kudos

I tested this before responding. I get the error "Specified Database is not found" when calling

    start database '\\machine\share\dir\database.db'

but no error when the statement is

    start database '\\\\machine\\share\\dir\\database.db'

You will need to use \\ and not \ in that statement when using UNC pathing. If you use a mapped share, you can refer directly to the file without the extra \'s.

    start database 'S:\dir\database.db'

Former Member
0 Kudos

Asif,

Chris's concern was not about performance but low level details, like, write flushing and write ordering that (if not guaranteed) can lead to out of order, incomplete and inconsistent writes to the file and possible corruption.

As to the file name concern, the use of '\' needs escaping by doubling those up.  If you have not not tried Chris's suggestion please do so ... and even if that still fails do note if the error has changed.

As to possible permissions, it is the database server process that needs the permissions, not the account you happen to be logged in with.   . . .
This is often an issue for databases when the server is ran as a Windows Service using the local SYSTEM account. \\.\SYSTEM has no network priviledges and so will not be able to locate any machines or shares on those for you.  If you can launch dbsrv<nn> or dbeng<nn> as a foreground process (from the cmd line) and your account has network priviledges on that share ... then that may work for you.And if it does you would need to change the account the service is running with, to one that has more priviledges.

Former Member
0 Kudos

Thanks Chris/Nick,

Its night time here. Even though I've been doing pretty much the same as suggested, but I would do a fresh re-try in the morning and get back. As chris been successful in starting a DB on a network share, I've hope that there is a way doing this. I'll keep you posted as I try.

Thanks a million 🙂

Former Member
0 Kudos

Hi Chris/Nick,

Good news.. it worked. As chris told me he was successful in starting a DB available through UNC, it gave me confidence of pushing it a little further. In my case, what I feel... dbisql window was actually not inheriting user permissions from the main Sybase-central window. So call was failing. I put the same one-liner into a stored procedure, and it worked like a charm.

It was definitely the permissions jargon that somehow was not proper inside dbisql window.

Thanks guys for the support. Hats off to both of you.

Below sample sp. for any similar issue in future.

Answers (0)