Detaching and attaching a database for my project

I hope this is the right forum for this question.

I am working with an asp.net project in Visual Web Developer 2005 Express. This is a starter kit project. There is a database that came with the project that I want to open up in the SQL Server 2005 Express management studio so that I can modify it.

I have detached the db in the VWD environment.But, I do not see this db in the db folder with in the SQL Server studio's IDE.I am assuming that I have to attach the database to the SQL Server management studio in order to work with it.Is this the correct way to do this type of thing? Is there a better way of doing it(a stored proc like mentioned below)?

I also have a question about the icons that pertain to this situation. I have noticed two variations of the same icon. I want to be sure I am interpretting these correctly. I am assuming that the icon that is a cylinder representing a db with the little

electrical plug coming out from behind it means that the db is attached. There is another version of this icon that has a red "x" over the plug. I am assuming that this means it is detached. Is this correct?

I have attached and detached dbs in Sql Server Express. Is the process the same for doing this with a project inVisual Web Developer? Is there a stored proc that I can use to detach from the SQL Server 2005 environment after I have made a databaseand attach this to my project in VWD in one step?

-thanks in advance

March 22nd, 2008 2:47pm

Yes, once you detach a database in Sql Server you need to copy the database physical files with the extension .mdf and ..ldf files to the destination server and from there you need to attach the database to Sql Server 2005. Refer this link to perform the attach operation, http://msdn2.microsoft.com/en-us/library/ms190209.aspx


If the db is attached then you can view the same in Sql Server management studio and access it as well. But if you have detached it then the db will be completely removed from Sql Server. If the database is attached you can find an entry in the sysdatabases table. You can use the below script to detach all the user databases,

declare @db varchar(40)
declare deep cursor for
select name from master..sysdatabases where name not in('master','model','msdb','tempdb')
open deep
fetch next from deep into @db
if @@fetch_status<>0
print' No user databases exist that needs to be detached '
while @@fetch_status=0
begin
print' sp_detach_db '+ @db
print ' go '
print ' Print ' + @db +' detached successfully '
print ''
fetch next from deep into @db
end
close deep
deallocate deep

- Deepak
Free Windows Admin Tool Kit Click here and download it now
March 22nd, 2008 3:01pm

Is my interpretation of the icons that I mentioned correct?

-thanks for the help

March 22nd, 2008 4:57pm

New,

Is this still an issue?

Thanks!

Free Windows Admin Tool Kit Click here and download it now
January 18th, 2014 8:54pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics