Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQL Server 2005 Connect at Run Time

0 views
Skip to first unread message

Daniele Pinai

unread,
Nov 28, 2009, 3:40:01 AM11/28/09
to
Hi.
I had created a DB on Sql server 2005 Instance
Db Named 'My_Db.mdf" with My_Db_Log.ldf file .

After that i had detached it.
I had copied on my USB Pen Driver. All works Fine.

Now the problem became HARDER (for me)

On my USB Pen Driver the Mdf and Ldb file must be named 'Demo_Db'
Demo_Db.Mdf and demo_Db_Log.Ldf

I had tried the simplest way, renamed the file, obviously this way is wrong

Can i rename phisical file name and connect to these fiel at run time ??

can my Mdf file call different Ldf file ?? ( the same but with other name)

I Hope to be explane

Thank's a Lots for your answer !!!!

Daniele Pinai
Italy

Erland Sommarskog

unread,
Nov 28, 2009, 5:41:29 AM11/28/09
to
Daniele Pinai (Daniel...@discussions.microsoft.com) writes:
> I had created a DB on Sql server 2005 Instance
> Db Named 'My_Db.mdf" with My_Db_Log.ldf file .
>
> After that i had detached it.
> I had copied on my USB Pen Driver. All works Fine.
>
> Now the problem became HARDER (for me)
>
> On my USB Pen Driver the Mdf and Ldb file must be named 'Demo_Db'
> Demo_Db.Mdf and demo_Db_Log.Ldf
>
> I had tried the simplest way, renamed the file, obviously this way is
> wrong
>
> Can i rename phisical file name and connect to these fiel at run time ??

You cannot connect directly to the files, you need to attach them to
SQL Server first. But obviously, the files can have any name when you
attach them. Look up the syntax for CREATE DATABASE FOR ATTACH in
Books Online.


--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

0 new messages