How to attach a database located in a different directory?

Hi,

I have developed an application using a SQL Server 2005 Express. Now I
am trying to deploy my application
using a connection string with attaches the database that I want to
deploy. I expect an installed SQL Server 2005 Express.

But it seems that it expect the files to be at the directory I have
detached the database file from.
I cannot make any assumptions about where the SQL server has instelled
to.

How can I change the location of the file?

Thanks

Lothar
0
Lothar
5/25/2010 1:33:21 PM
sqlserver.programming 1873 articles. 0 followers. Follow

4 Replies
1484 Views

Similar Articles

[PageSpeed] 54

On Tue, 25 May 2010 06:33:21 -0700 (PDT), Lothar Behrens
<lothar.behrens@lollisoft.de> wrote:

>Hi,
>
>I have developed an application using a SQL Server 2005 Express. Now I
>am trying to deploy my application
>using a connection string with attaches the database that I want to
>deploy. I expect an installed SQL Server 2005 Express.
>
>But it seems that it expect the files to be at the directory I have
>detached the database file from.
>I cannot make any assumptions about where the SQL server has instelled
>to.
>
>How can I change the location of the file?
>
>Thanks
>
>Lothar

Hi lother

Are you using the full path and filename?


John
0
John
5/25/2010 2:09:55 PM
On 25 Mai, 16:09, John Bell <jbellnewspo...@hotmail.com> wrote:
> On Tue, 25 May 2010 06:33:21 -0700 (PDT), Lothar Behrens
>
>
>
>
>
> <lothar.behr...@lollisoft.de> wrote:
> >Hi,
>
> >I have developed an application using a SQL Server 2005 Express. Now I
> >am trying to deploy my application
> >using a connection string with attaches the database that I want to
> >deploy. I expect an installed SQL Server 2005 Express.
>
> >But it seems that it expect the files to be at the directory I have
> >detached the database file from.
> >I cannot make any assumptions about where the SQL server has instelled
> >to.
>
> >How can I change the location of the file?
>
> >Thanks
>
> >Lothar
>
> Hi lother
>
> Are you using the full path and filename?
>
> John- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

You could simply repeat my failures to attach a database file by
creating one and detaching it:

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data>sqlcmd -s
cyborg
1> create database Test
2> go
1> sp_detach_db Test
2> go
1> sp_attach_db @dbname=3DTest, @filename1=3D'Test.mdf'
2> go
Meldung '5105', Ebene '16', Status '2', Server 'CYBORG\SQLEXPRESS',
Zeile 1
'Fehler beim Aktivieren der Datei. Der physikalische Dateiname
'Test.mdf' ist m=F6
glicherweise falsch. Diagnostizieren und beheben Sie zus=E4tzliche
Fehler, und wie
derholen Sie den Vorgang.'
1> sp_attach_db @dbname=3DTest, @filename1=3D'.\Test.mdf'
2> go
Meldung '5105', Ebene '16', Status '2', Server 'CYBORG\SQLEXPRESS',
Zeile 1
'Fehler beim Aktivieren der Datei. Der physikalische Dateiname '.
\Test.mdf' ist
m=F6glicherweise falsch. Diagnostizieren und beheben Sie zus=E4tzliche
Fehler, und w
iederholen Sie den Vorgang.'
1> sp_attach_db @dbname=3DTest, @filename1=3D'.\\Test.mdf'
2> go
Meldung '5105', Ebene '16', Status '2', Server 'CYBORG\SQLEXPRESS',
Zeile 1
'Fehler beim Aktivieren der Datei. Der physikalische Dateiname '.\
\Test.mdf' ist
 m=F6glicherweise falsch. Diagnostizieren und beheben Sie zus=E4tzliche
Fehler, und
wiederholen Sie den Vorgang.'

This is even an isolated test on the same database instance. So why is
this not working?

Using a simple sqlcmd -s cyborg -i SQLScript.txt works for both,
creating a database and populating it with a schema.

This would be a solution, if I could add optional steps to the
installer project in visual studio (not installshield), but that is
another story. (RTFM)

Thanks

Lothar
0
Lothar
5/25/2010 5:33:27 PM
"Lothar Behrens" <lothar.behrens@lollisoft.de> wrote in message 
news:278a525f-075e-475f-b1ec-43fbdbb6f725@l6g2000vbo.googlegroups.com...
> On 25 Mai, 16:09, John Bell <jbellnewspo...@hotmail.com> wrote:
>> On Tue, 25 May 2010 06:33:21 -0700 (PDT), Lothar Behrens
>>
>>
>>
>>
>>
>> <lothar.behr...@lollisoft.de> wrote:
>> >Hi,
>>
>> >I have developed an application using a SQL Server 2005 Express. Now I
>> >am trying to deploy my application
>> >using a connection string with attaches the database that I want to
>> >deploy. I expect an installed SQL Server 2005 Express.
>>
>> >But it seems that it expect the files to be at the directory I have
>> >detached the database file from.
>> >I cannot make any assumptions about where the SQL server has instelled
>> >to.
>>
>> >How can I change the location of the file?
>>
>> >Thanks
>>
>> >Lothar
>>
>> Hi lother
>>
>> Are you using the full path and filename?
>>
>> John- Zitierten Text ausblenden -
>>
>> - Zitierten Text anzeigen -
>
> You could simply repeat my failures to attach a database file by
> creating one and detaching it:


Looking at your steps I see you've ignored what John Bell pointed out - 
you're not using the full path. @filename requires the full path, not a 
relative path. See BOL for more details.

-- 
Dan 

0
Dan
5/26/2010 9:17:23 AM
Hi Lothar

Your re-creation is not what I interpretted you said you were doing,
your post implies that you are using the AttachDBFileName option in
the connection string i.e using XCopy deployment.

Using sp_attach_db will not move the database files. If you had
specified a full path name then your script would work but without
separately moving/copying the files they do not change location. If
you did move the all the database files (mdf and ldf files)  then you
would also need to specify the ldf file in the sp_attach_db statement.
If you used sp_attach_single_file_db the ldf file will be recreated in
the original location. In either case it would be better moving
forwards if you start using CREATE DATABASE instead.

You haven't shown SQLScript.txt, but my guess is that it had the full
path when it works.

John

On Tue, 25 May 2010 10:33:27 -0700 (PDT), Lothar Behrens
<lothar.behrens@lollisoft.de> wrote:

>On 25 Mai, 16:09, John Bell <jbellnewspo...@hotmail.com> wrote:
>> On Tue, 25 May 2010 06:33:21 -0700 (PDT), Lothar Behrens
>>
>>
>>
>>
>>
>> <lothar.behr...@lollisoft.de> wrote:
>> >Hi,
>>
>> >I have developed an application using a SQL Server 2005 Express. Now I
>> >am trying to deploy my application
>> >using a connection string with attaches the database that I want to
>> >deploy. I expect an installed SQL Server 2005 Express.
>>
>> >But it seems that it expect the files to be at the directory I have
>> >detached the database file from.
>> >I cannot make any assumptions about where the SQL server has instelled
>> >to.
>>
>> >How can I change the location of the file?
>>
>> >Thanks
>>
>> >Lothar
>>
>> Hi lother
>>
>> Are you using the full path and filename?
>>
>> John- Zitierten Text ausblenden -
>>
>> - Zitierten Text anzeigen -
>
>You could simply repeat my failures to attach a database file by
>creating one and detaching it:
>
>C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data>sqlcmd -s
>cyborg
>1> create database Test
>2> go
>1> sp_detach_db Test
>2> go
>1> sp_attach_db @dbname=Test, @filename1='Test.mdf'
>2> go
>Meldung '5105', Ebene '16', Status '2', Server 'CYBORG\SQLEXPRESS',
>Zeile 1
>'Fehler beim Aktivieren der Datei. Der physikalische Dateiname
>'Test.mdf' ist m�
>glicherweise falsch. Diagnostizieren und beheben Sie zus�tzliche
>Fehler, und wie
>derholen Sie den Vorgang.'
>1> sp_attach_db @dbname=Test, @filename1='.\Test.mdf'
>2> go
>Meldung '5105', Ebene '16', Status '2', Server 'CYBORG\SQLEXPRESS',
>Zeile 1
>'Fehler beim Aktivieren der Datei. Der physikalische Dateiname '.
>\Test.mdf' ist
>m�glicherweise falsch. Diagnostizieren und beheben Sie zus�tzliche
>Fehler, und w
>iederholen Sie den Vorgang.'
>1> sp_attach_db @dbname=Test, @filename1='.\\Test.mdf'
>2> go
>Meldung '5105', Ebene '16', Status '2', Server 'CYBORG\SQLEXPRESS',
>Zeile 1
>'Fehler beim Aktivieren der Datei. Der physikalische Dateiname '.\
>\Test.mdf' ist
> m�glicherweise falsch. Diagnostizieren und beheben Sie zus�tzliche
>Fehler, und
>wiederholen Sie den Vorgang.'
>
>This is even an isolated test on the same database instance. So why is
>this not working?
>
>Using a simple sqlcmd -s cyborg -i SQLScript.txt works for both,
>creating a database and populating it with a schema.
>
>This would be a solution, if I could add optional steps to the
>installer project in visual studio (not installshield), but that is
>another story. (RTFM)
>
>Thanks
>
>Lothar
0
John
5/26/2010 1:09:41 PM
Reply:

Similar Artilces:

uuencoded attachment from mailx is embedded instead of attached
Since I applied the August 2004 version of the post ex2000 sp3 roll-up and the latest April Microsoft secuirty patches, when our unix mailx app sends mail to our Exchange 2k server, the uuencoded attachment is embedded in the body of the message instead of being received as an attachment. Being embedded in the message body turns it into unuseable garbage. We have not made any changes to the unix box, only the exchange box. Has anyone else experienced this problem or anyone know what the solution may be? Thanks ...

Printing
After I send an email with attachments, when I print it from the sent items the attachements do not show up on the printed copy. Is there a setting I can change to have these attachments print so I know what files were included as attachments? Thanks, Roger K. On Wed, 15 Dec 2004 15:37:01 -0800, "Roger K" <RogerK@discussions.microsoft.com> wrote: >After I send an email with attachments, when I print it from the sent items >the attachements do not show up on the printed copy. Is there a setting I >can change to have these attachments print so I know what files...

SQL Database Username for Dynamics RMS
I am new to MS Dynamics RMS and installed on single stand alone machine for sample store prior to joing computer to domain and making live. I cant connect to the database (Included SQL 2005) because I do not know the default username. I know the password and try to connect to local but keep getting denied. Is the default username the logged in user, admin, administrator, computer name, etc? "Charles Nuglene" wrote: > I am new to MS Dynamics RMS and installed on single stand alone machine for > sample store prior to joing computer to domain and making live. I cant &...

Database with Multiple Users
I am trying to create a database that has the potential for many users. I recently learned how to set securities and passwords for the database, but I still can't figure out one thing: Is there a way to have a database with multiple users, but restrict what each person sees? The way my database is set up now, all information is stored in a table, and the user would fill out the form to enter their information. These users will also have the ability to edit their information later. On both the table and the form, however, other users can still see all of the information, ...

Attachment Read only
Hi, When I open a Word attachment - it shows readonly - actually it is not readonly - any ideas? - OL2003 Rgds Dear, It seems you are opening the attachment in OL Reading preview - Open the mail(double click on the mail) and then read the attachment. Hope this helps you more Regards APK "Jsingh" wrote: > Hi, > > When I open a Word attachment - it shows readonly - actually it is not > readonly - any ideas? - OL2003 > > Rgds > Jsingh, you wrote on Tue, 17 Jan 2006 01:03:02 -0800: > When I open a Word attachment - it shows readonly - actually i...

Attach a file in knowledge base
Hi all, Is anyone know that Can we attach a file like PDF or DOC document in an article under the CRM knowledge base? I think it doesn't make sense to only type it in or copy the text into the article. Thanks in advance, DK. I had the same problem and apparently this is not a feature in MS CRM 3.0. According to a CRM representative the answer is that you cannot attach a document to a knowledge base article. "DK" wrote: > Hi all, > > Is anyone know that Can we attach a file like PDF or DOC document in an > article under the CRM knowledge base? I think it doe...

Automaticly open attachment and print attachment
Hello, Is there a way to automaticly open a attachment and print it? I played with the rules wizard but there i can only get the message openend and printed. I use Outlook 2003 Thanks. You'll need a 3rd party utility. Look for solutions here: http://www.slipstick.com/addins/auto.htm -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Author, Google and Other Search Engines (Visual QuickStart Guide) Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http:/...

Getting rid of Workspaces links after restoring PS2007 Databases
Hi, We provisioned a new PWA instance using a backup of the 4 project DB. We did not bring the old content database because we did not want the workspaces. My problem now is that in the home page, the "project Workspace" WebPart displays all the workspaces (from the old environment) and they do not exist in my new environment. I did not find any way to get rid of these non-existing workspaces. (around 400 of them) Should I update the "MSP_Projects" table in "Published DB" ? The fields are WPROJ_STS_SUBWEB_NAME and WSTS_SERVER_UID. Anybod...

Open a report in a different mdb
If this is possible, how would I do it using "DoCmd.OpenReport"? Dim appAccess As Access.Application Set appAccess = New Access.Application appAccess.OpenCurrentDatabase "C:\Folder\File.mdb" appAccess.DoCmd.OpenReport "NameOfReport" Once you're done with the report, you need appAccess.CloseCurrentDatabase appAccess.Quit Set appAccess = Nothing -- Doug Steele, Microsoft Access MVP http://www.AccessMVP.com/DJSteele (no e-mails, please!) "JimP" <j_pockmire@comcast.net> wrote in message news:ZeGdnVeYY9Vbz...

Adding Individual Mulitple Domains to Active Directory
We are a simple single domain using 2003 Server. Our company is now merging with several other companies. Using AD how do I add domains of the other companies and yet have each domain be separate from the others? For example our domain would be xyz.com, now I need to add abc.com to our AD. I don't want to have abc.xyz.com - I want them both to be separate but using the same AD. I'm told there is an article in Microsoft on how to setup multiple domains in a single AD environment but I haven't found it yet. Could I not use the current DC that houses our AD? We don'...

directory structure xsl transformation question
I really have 2 questions regarding the following xml snippet. The xml is a directory representation. <?xml version="1.0" standalone="yes"?> <FileSystem> <Row> <ID>1</ID> <Name>Root</Name> <Directory>Root</Directory> <Dir>true</Dir> <ParentID>0</ParentID> </Row> <Row> <ID>2</ID> <Name>c:\temp\boot\windowsapplication1\bin</Name> <Directory>c:\temp\boot\windowsapplication1\bin</Directory> <Dir>true<...

Oulook 2000 Blocking Attachments! Reposted
Hi ONG, I am running Ms-Outlook 2000 Service pack 3, on a Windows pro 2000 Service pack 4. Standalone machine. Recently my mail client has been blocking my email attachments, i have received two replies from the newsgroup describing Level1 security in Outlook, also a link to a site containing all the releative information regarding the subject. But no matter what i try Outlook still wont allow the access to the attachment. I created the new Key and the necessary String Value, i have even tried to use the ( . ) character before the file ext, also i have tried it without the ( .) character, no...

How to Find the Message that contained The Attachment of a Known File-Name.
Is there some way to search through a list of emails in Outlook 2003 to find the one that contains an attachment of a specific file name? I am often trying to track down the message that accompanied an attachment with a known file-name amongst thousands of messages in one mailbox. Regards, AndyH If attached to an Exchange server, I would, as an admin, use a utility server-side. From the client, I'm not sure Outlook can do it on its own. Hopefully, I'm wrong. Some of the desktop search applications have this functionality though. "AndyH" <andyh@triode.net.au&g...

attachments do not forward
I want to forward e-mails which come to me with attachments. I want these attachments to forward along with the message and they do not. How can I make this happen? Is there a setting to enable this? ...

The receipt format is totally different from the preview
My printer is EPSON TM88III and I installed the OPOS driver. The receipt printed has a different font and layout from the one in the receipt preview, e.g., in the preview the "Sales Receipt" is in a white box with black border while in the receipt it is in a black box. How can I solve this problem? Thank you! -- Nothing Is this all because of the OPOS driver? -- Nothing "NothingMuch" wrote: > My printer is EPSON TM88III and I installed the OPOS driver. The receipt > printed has a different font and layout from the one in the receipt preview, > e.g., in...

Editing attachments in Outlook XP
If you open a Word doc that is attached to an email & make edits to it, does it save it anywhere else other than in the email? Has anyone ever seen it not save the edits at all? It may be in a secure folder under the Temporary Internet Folder as per http://support.microsoft.com/?kbid=296115 "DonnaC" <anonymous@discussions.microsoft.com> wrote in message news:052d01c3be9b$44ebd3a0$a101280a@phx.gbl... > If you open a Word doc that is attached to an email & make > edits to it, does it save it anywhere else other than in > the email? > Has anyone ever seen it...

device name different in Devices and Device Manager
Hello. I have developed a device and a driver. I provide the Inf file and everything works well for installing it from WinXP to W7 64 bits. My Inf file provides a Class for that device. Thanks to some instructions like DeviceIcon, I can specify a localized name and an Icon for the class and the device instances for the Device Manager. It works well. However, when the user does not open the advanced Device Manager, but only the "Devices and Printers" pane, my device instance appears with a firmware hard-coded name. I would like to override that name with a "display n...

attachments.......
Is there a way to only prevent staff from sending attachments internally? I am using Exchange 2003 and office 2003. Thanks, Crank down the internal message size limits to a value that makes sense to you. On Tue, 11 Jan 2005 17:03:07 -0500, "Dooma" <Say-no-to-spam@hotmail.com> wrote: >Is there a way to only prevent staff from sending attachments internally? I >am using Exchange 2003 and office 2003. > > >Thanks, > > ...

how does the WLM 2011 beta contact system / database work?
Using WLM 2011 beta (Build 15.4.3002.0810) German version, on a 32-bit Win7 Ultimate system. Everything works relatively fine but i am confused with the Windows Contacts. As i have a live mail account, i can synchronize my contacts on other computers. But how has this system changed from OutlookExpress over WindowsMail to WLM? And is there a major difference to OUTLOOK (2007 or 2010) contacts? I have noticed that compatibility to certain mobile phones is no longer given. Have a SonyEricsson w995 and SonyEricsson offers a sync software called "pc suite" which h...

How to give a string of data into different columns
Super expert, If I have cell containing a series of data like this .... 1,12,9 1,2,9 1,22,17,18 23,23,1,9 24,21,1 1,23,11 22,1 2,3 Is it possible to use function or command to split them into columns? 1 12 9 1 2 9 1 22 17 18 23 23 1 9 24 21 1 1 23 11 22 1 2 3 I don't want to use "TEXT TO COLUMN" as some of the addresses can be overwritten. Thanks so much, Regards, Elton Hi 'Elton Law' Try the below =TRIM(MID(SUBSTITUTE("," & $A$1& REPT(",",6),",", REPT(CHAR(32),255)),COLUMNS($B$1:...

Have to scroll to see full list of attachments in Outlook 2007?
A colleague of mine keeps sending me HTML emails in Outlook with multiple attachments, but the full list of attachments does not appear all at once on the screen. There is a scroll bar on the FAR right next to the attachments, and you have to scroll down through the list of attachments to see all of the attachments (I can send a screen shot to better explain this). So for example, if an email has four attachments, I only see the first three on the screen, and then I have to scroll down to see the fourth attachment. This is very confusing as I can easily "miss" an attach...

print out messages with list of attachments
Hello there, when printing out a message/email in full, how do I get outlook t print the list of attachments? Cheers, Wi ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com found it in the newsgroups :-) http://support.microsoft.com/default.aspx?scid=kb;en-us;821840 ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ ...

remove attachment on reply
Some how I have set my outlook to save the replying email as an atachment and I would prefer it just be in the text form like before. Apparently I changed something or hit something that did this and I wold like to fix it. To delete attachments from messages in Outlook: Double-click on the desired message to open it in its own window. Click on the attachment you want to remove with the right mouse button. Select Remove from the menu. Close the message window. Click OK in the Do you want to save changes? dialog. calender, items, reaccuring, wrote: >Some how I have set my...

.xls attachment
Hi, can anyone help me? I'm quite new to the whole computer/techno life and have been trying for over 2 hours to find what I want! A friend has sent an e-mail with an attachment which has a .xls file extension. However I try, I am unable to open the attachment. I've downloaded various software at 'my machine's' recommendation including a works conversion thing for Word but still no luck. I hope it's something really simple which can be sorted by someone with a bit of a clue but I'm starting to get tied up in knots. I wouldn't mind but the attachment soun...

How to have same editable element in the same position on different drawings
Hi all, this is my first message on this newsgroup, i've looked around if you have already answered to this question but i was not able to find this. This is my problem: I'm using Visio to document the wireframes of the pages of a new website. As you know every page of a website usually has the same header, so to not draw it in each drawings i've used for it a specific background i use in all the pages. I need also to insert, for example, the breadcrumbs (you know that things that remember you where on the site you are like Home > Products > Motherboard) always in the same ...