Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 plz help in attaching the Database

Author  Topic 

vedjha
Posting Yak Master

228 Posts

Posted - 2008-12-22 : 05:45:52
hello,

i m facing problem to attaching database. there is a file with extension *.mdf but there is no *.ldf. then how can i attach the Database. it's urgent .plz help me...


Ved Prakash Jha

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-22 : 05:51:55
See "sp_attach_single_file_db" in Books Online.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

vedjha
Posting Yak Master

228 Posts

Posted - 2008-12-22 : 06:29:15
i were wrote the query as :

sp_attach_single_file_db 'Database','C:\Documents and Settings\Administrator\Desktop\marriageofficiant\App_Data\Database.ldf'

but it gives an error as:

Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "C:\Documents and Settings\Administrator\Desktop\marriageofficiant\App_Data\Database.ldf". Operating system error 2: "2(The system cannot find the file specified.)".


Ved Prakash Jha
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-22 : 06:32:17
That is NOT the correct way to use the stored procedure. Did you read Books Online?
In Books Online there is written that the log file will be crated for you if you supply the database file.

sp_attach_single_file_db 'Database','C:\Documents and Settings\Administrator\Desktop\marriageofficiant\App_Data\Database.mdf'



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

NeilG
Aged Yak Warrior

530 Posts

Posted - 2008-12-22 : 06:52:16
sp_attach_single_file_db 'Database','C:\Documents and Settings\Administrator\Desktop\marriageofficiant\App_Data\Database.ldf'

Was the ldf part a mistake on your last post, and is the desktop folder really the correct loaction of the file
Go to Top of Page

vedjha
Posting Yak Master

228 Posts

Posted - 2008-12-22 : 07:10:41
thnks *.ldf file has created . but it does not show any table or procedure .
but there is....

what may be problem...

Ved Prakash Jha
Go to Top of Page

vedjha
Posting Yak Master

228 Posts

Posted - 2008-12-22 : 07:15:04
thnks *.ldf file has created . but it does not show any table or procedure .
but there is....

what may be problem...

Ved Prakash Jha
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-12-22 : 07:47:14
quote:
Originally posted by vedjha

thnks *.ldf file has created . but it does not show any table or procedure .
but there is....

what may be problem...

Ved Prakash Jha



Attach mdf file not ldf file with sp.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-22 : 07:50:18
If you have attached the mdf file and there is nothing in it, it means the database is empty.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -