Attaching A Removable Database
Dec 1, 2000
Hi,
I wanted to create a removable SQL Server 7.0 database. So I created the database using the sp_create_removable system stored procedure, imported objects and data, ensured that the database is configured properly for distribution on removable media (using sp_certify_removable system stored procedure), and detached it from original SQL Server. So far, so good. The database consists of 3 files: MYDB_SYS, MYDB_DATA and MYDB_LOG. I copied
MYDB_DATA on a CD, and MYDB_SYS and MYDB_LOG on hard disk of a different server. If I execute the following statement:
Execute sp_attach_db
@dbname = 'MYDB'
, @filename1 = 'C:MYDB_SYS.MDF'
, @filename2 = 'E:MYDB_DATA.NDF'
, @filename3 = 'C:MYDB_LOG.LDF'
I get the following messages:
Server: Msg 5105, Level 16, State 4, Line 1
Device activation error. The physical file name 'E:MYDB_DATA.NDF' may be incorrect.
Server: Msg 945, Level 14, State 1, Line 1
Database 'MYDB' cannot be opened because some of the files could not be activated.
Server: Msg 1813, Level 16, State 1, Line 1
Could not open new database 'MYDB'. CREATE DATABASE is aborted.
I can successfully execute the above statement if I make MYDB_SYS.MDF file read only, but then MYDB is created as read only, and this option can not be changed.
Please, help.
Maja
View 1 Replies
ADVERTISEMENT
Mar 18, 2007
please ,
im already designed a database, what i can do to make it work in different paltform ex. (mysql)
?
?
View 3 Replies
View Related
Apr 3, 2000
Does anyone out there work with databases created using sp_create_removable?
I am encountering a situation that is a difference between 6.5 and 7.0 handling of these types of databases. In 6.5, our product creates a removable database on a fixed hard drive. When the user is ready to move the database to a jazz or zip drive, we set the database readonly and remove the log file. No problems. We can use sp_dbinstall witout a log file and everything works just fine.
In 7.0 we do the same thing, however, when we attach the database via sp_attach_db (which replaced sp_dbinstall), SQL Server 7 creates a new log file.
Is there any way to make SQL Server NOT re-create this log file?
View 1 Replies
View Related
Oct 4, 2006
Hi there,
I got this error when i tried to attach the adventureworks database and SSIS training database.
an exception occurred while executing a transact-sql statement or batch
(microsoft.sqlserver.connectioninfo)
could not find row in sysindexes for database ID 17, object ID 1, index ID 1. Run DBCC
checktable on sysindexes.
I join join a network domain for my computer. Previously it doesnt have this problem.
View 1 Replies
View Related
Apr 24, 2006
Hello Everyone,
I am new to SQL Server Administration/
We have a distributed system running on IP-VPN Network. Every site in the network has one SQL Server 2000 standard server database running on Windows 20003 server.
I am setting up Merge replication on every site where the database is updates are consolidated in the main database.
I have no problem in setting up merge replication, and system is working ok as of now.
But some of remote sites are located in different geographical locations and I want to transfer the Initial snapshots using a removable device, which I want to manually restore at those remote sites, and then enable the merge replication.
I have already read thru many manuals, websites etc to find out how to restore the initial snapshots on the subscriber, but can not find any info.
This is PUSH replication where the distributor is pushing the updates to the different remote subscribers.
My deadline for implementation is approaching and I will very much appreciate any help in this matter.
Ravi Shankar
View 3 Replies
View Related
Apr 2, 2008
The situation :
I am making mass changes to my program and database.
The goal is to not make changes to the database at the customer sites, but to clone their current database, and work with that one.
The solution:
I wrote code and queries to detach the database, copy it to another directory on the same computer with a different name, then attach it with the new name.
The process is:
run : sp_detach_db "' + aDatabase + '", ''false'';' (aDatabase is the original database name)
Then, in code, delete the original .ldf file, and copy the database.mdf file to new directory with new name.
then run (for both the new and the original databases):
Create Database "' + aDatabase + '" on
(NAME = ''' + aDatabase + ''', FILENAME = ''' + FormatFilePath(aPath) + aDatabase + '.mdf''
For Attach
This works, up to a point.
The problem :
When I inspect the properties of the newly attached database, with the new name and new directory, the logical name of the database is still the original name.
I TRIED running this query :
sp_attach_single_file_db @dbName= "' + aDatabase + '",'
@physname= ''' + FormatFilePath(aPath) + aDatabase + '.mdf'
but it returns(even though I have deleted the .ldf files for the original dataset) :
Could not open new database 'Test62'. CREATE DATABASE is aborted.
Cannot create file 'E:Data6Test62Test62_log.LDF' because it already exists. Change the file path or the file name, and retry the operation.
File activation failure. The physical file name "E:Data6TestTest_log.LDF" may be incorrect.
(original database name = data6 est est, new database name is data6 est62 est62)
Is there a way to do this? Or do I just need to give it up?
View 1 Replies
View Related
Oct 11, 2007
hello
i am having a problem attaching database.
The Problem :
I have created a database using sqlserver express edition.now i have installed enterprise edition ,so i am attaching the database which is created in sqlserver express edition into the enterprise edition.it is showing error
TITLE: Microsoft SQL Server Management Studio
------------------------------
Attach database failed for Server 'SRINIVAS'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Could not find row in sysindexes for database ID 13, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
Could not open new database 'FMS'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 602)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=602&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
Can anyone Help me
thanks
View 1 Replies
View Related
Jun 12, 2008
i try to attach sqlserver db but i get this error
TITLE: Microsoft SQL Server Management Studio Express------------------------------
Attach database failed for Server 'srvsqlsrv'. (Microsoft.SqlServer.Express.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
------------------------------ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)
------------------------------
One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup. (Microsoft SQL Server, Error: 5173)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.2047&EvtSrc=MSSQLServer&EvtID=5173&LinkId=20476
------------------------------BUTTONS:
OK------------------------------
what i will do to solve this error
View 1 Replies
View Related
May 26, 2007
Hi all,
I am facing a problem during attaching a database (.mdf and .ldf files are copied fro another server). the message I am getting as follows:
messages was from 'Microsoft SQL Server Management Studio Express':
===================================
Attach database failed for Server 'CTPL-1'. (Microsoft.SqlServer.Express.Smo)
------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.Exceptio nTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
------------------------------
Program Location:
at Microsoft.SqlServer.Management.Smo.Server.AttachDa tabase(String name, StringCollection files, String owner)
at Microsoft.SqlServer.Management.SqlManagerUI.Attach DatabaseData.PrimaryFile.Attach()
at Microsoft.SqlServer.Management.SqlManagerUI.Attach Database.SendDataToServer()
===================================
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)
------------------------------
Program Location:
at Microsoft.SqlServer.Management.Common.ServerConnec tion.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Common.ServerConnec tion.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.ExecutionManage r.ExecuteNonQuery(StringCollection queries)
at Microsoft.SqlServer.Management.Smo.Server.AttachDa tabaseWorker(String name, StringCollection files, String owner, AttachOptions attachOptions)
at Microsoft.SqlServer.Management.Smo.Server.AttachDa tabase(String name, StringCollection files, String owner)
===================================
Could not find row in sysindexes for database ID 8, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
Could not open new database 'mci'. CREATE DATABASE is aborted. (.Net SqlClient Data Provider)
------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=602&LinkId=20476
------------------------------
Server Name: (local)
Error Number: 602
Severity: 21
State: 50
Line Number: 1
------------------------------
Program Location:
at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQuer yTds(String methodName, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNo nQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.SqlServer.Management.Common.ServerConnec tion.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
===============================================
********************************
the followings are the command and mesage from Query Analyzer:
*****************************************
command:
-- =============================================
-- Attach database via sp_attach_db
-- =============================================
EXECUTE sp_attach_db @dbname = N'mci',
@filename1 = N'd:ifgldatabasemci.mdf',
@filename2 = N'd:ifgldatabasemci_log.ldf'
GO
*****************************************
message:
Server: Msg 602, Level 21, State 50, Line 1
Could not find row in sysindexes for database ID 8, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
Connection Broken
*******************************************
I am new to MS SQL Server and unable to solve the problem. Can anyone help me in this metter.
Thanks in advance.
View 2 Replies
View Related
Apr 12, 2013
there was a failure due to power shutdown,and the .mdf and .ldf files on the DB is not longer available. there is a backup done 5days ago with the title nice_cls.BAK. How do i restore or reattach the .bak file on the NICE-CLS database.
View 10 Replies
View Related
Feb 22, 2004
Hi,
My current server going nuts it restaring every one hour, I have 200+GB (80+ files) database size. The network guyes don't have backup. This is what I am trying to do. I have detach my database. I have copied all the file to new server. Now i am trying to attach using create, I can't just use attach because 16+ files. When I run following on my server it gives me an error.
Any help will be highly appreciated.
please email me the answer if you have.
Thanks.
Samir
CREATE DATABASE KEYFILE
ON PRIMARY (NAME= 'KEYFILE001' FILENAME='F:KEYFILEDBKEYFILE001.MDF')
ON SECONDARY (NAME='KEYFILE002' FILENAME='F:KEYFILEDBKEYFILE002.NDF')
ON SECONDARY (NAME='KEYFILE003' FILENAME='F:KEYFILEDBKEYFILE003.NDF')
ON SECONDARY (NAME='KEYFILE004' FILENAME='F:KEYFILEDBKEYFILE004.NDF')
ON SECONDARY (NAME='KEYFILE005' FILENAME='F:KEYFILEDBKEYFILE005.NDF')
ON SECONDARY (NAME='KEYFILE006' FILENAME='F:KEYFILEDBKEYFILE006.NDF')
ON SECONDARY (NAME='KEYFILE007' FILENAME='F:KEYFILEDBKEYFILE007.NDF')
ON SECONDARY (NAME='KEYFILE008' FILENAME='F:KEYFILEDBKEYFILE008.NDF')
LOG ON SECONDARY (NAME= 'KEYFILE_LOG' FILENAME='F:KEYFILEDBKEYFILE_LOG.LDF')
FOR ATTACH
View 1 Replies
View Related
Jul 19, 2006
hi all
i am working on sql server 2005
When i am trying to attach database in my server i am getting following error. Plz help me to fix this error.
the error as as follows :
Attach database failed for Server 'myserver'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Could not find row in sysindexes for database ID 10, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
Could not open new database 'ReportServer'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 602)
View 2 Replies
View Related
Jul 19, 2006
hi all
i am working on sql server 2005
When i am trying to attach database in my server i am getting following error. Plz help me to fix this error.
the error as as follows :
Attach database failed for Server 'myserver'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Could not find row in sysindexes for database ID 10, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
Could not open new database 'ReportServer'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 602)
View 1 Replies
View Related
Oct 12, 2005
Hi,I am tring to attached a database in SQL using the following command.Can any one please help. Basically I have a MDF and LDF files which Ineed to open in SQL 7.0, these files are from a diff SQL7.0 machinewhich is crashed.PLEASE HELP. There are many valuable info in the database.Command :EXEC sp_attach_db @dbname = N'Digitalindia',@filename1= N'C:SqlMaster.MDF',@filename2= N'C:SqlMaster.LDF'Error :Server: Msg 5172, Level 16, State 15, Line 1The header for file 'C:SqlMaster.MDF' is not a valid database fileheader. The PageAudit property is incorrect.*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
View 1 Replies
View Related
Jul 20, 2005
Hiis it possible to attach a database when a log file is missing?My database had one .MDF file and 2 .LDFs. I lost one of the .LDFs. Is itpossible to recover any data?Tegie
View 1 Replies
View Related
Jul 20, 2005
Q1.)In SQL Server 2000, is it always possible to use copies of thedata and transaction log files of a database from one server toreattach to a new database on another server, or even to the sameserver, without first detaching from the existing database?Books Online says that detaching a database closes the data and logfiles cleanly. I read some where that some times, it is possible toattach without detaching, if the data and log file are in stablestate.This is what I tried - Tried to copy Northwind.mdf and ldf files usingwindows explorer and it gave an error message that the files are inuse. I shutdown the server and now I could easily copy them. Afterthat I renamed these files and successfully attached them as a newdatabase.Q2.)Is it possible to do the same with large production databases?Q3.) Please explain what goes on during detaching /attaching process.Thanks in advanceRavi
View 1 Replies
View Related
Mar 21, 2007
Today I installed SQLEXPR.EXE that I found here:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.3042&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476
I made sure that I downloaded the 64-bit version.
I then wanted to download and install the Adventure Works database located here: http://www.microsoft.com/downloads/details.aspx?familyid=E719ECF7-9F46-4312-AF89-6AD8702E4E6E&displaylang=en
Since I am running Vista 64-bit, I downloaded and installed AdventureWorksDB_x64. It wouldn't install. I got "Access is denied" and CREATE FILE error plus several others.
I then uninstalled it and downloaded AdventureWorksDB - this is the X86 version. It installed fine.
Can anyone explain what am I missing? Thanks!
View 1 Replies
View Related
Nov 16, 2006
Hi Mike,
I've had a look at the white paper on use instances and also stopped using Management Studio, as you suggested. The problem is that I can run my application from VWD quite happily, until for no reason the application can't connect to the database. This happens ramdomly and is very frustrating. I have worked out a way to correct this problem with the following method (I don't know if this is correct but it's the only work around I know.
1) I close down VWD and open Management Studio,
2) I right click to attach a database, and then navigate to the .mdf file for the database, and click to attach it. I then delete the existing icon for that database (which I can't acess anyway, it only shows me the main icon but not the tables)
3) I rename the new instance of the database to the correct name (minus path info etc)
4) I create an SQL script as follows:
EXEC sp_grantlogin 'jonASPNET'
(This line executes correctly),
Then I enter these lines:
USE BalloonShop *name of database *
EXEC sp_grantdbaccess 'jonASPNET'
(At this stage when I execute the query, Management Studio informs me that this name already exists in the database and so doesn't execute)
5) I now close out of Management Studio and re-open VWD, and I can now run my application correctly.
I know I've got some configuration settings wrong somewhere but I find the whole user instance thing confusing. For the record I'm running the appllication through VWD's built in web server, I did originally have it through IIS but I moved it (this will explain the confusion of locations from my first post, I gave you the original location, sorry about that).
Any advice you can give would be gratefully recieved, ie is there an easy way to reconfigure my settings to make everything work as expected or have I got to start the database again from scratch (not a pleasent thought). Also is there an idiots guide to SQL Server Express anywhere that I can read.
Jon
ps I've just realised that I get the 'can't connect to database problem when running the application after I've made a change to the database from VWD ie adding a new stored proceedure, Don't know if this helps, but better you get the full picture.
View 1 Replies
View Related
Jul 24, 2007
Hi all,
I have deleted the .ldf file now i am having only the .mdf file. Is it possible to attach the database without shutdown the sql server.
Thanks.
View 9 Replies
View Related
May 4, 2006
I've created a simple database using Visual Web Developer Express.
I is located in "C:Documents and SettingsRomanMy DocumentsVisual Studio 2005WebSitesNewSiteApp_Data" Folder.
When I try to attach this database using SQL SERVER Management Studio Express: it doesn't allow me to view the contents of "C:Documents and SettingsRoman" Folder - it just won't expand any further!!!!!
Anyone had a similar problem. I think it is some sort of a bug, maybe
Please help!
Thanx
Michael
View 1 Replies
View Related
Nov 7, 2006
Hi Mike,
I hope you can help me with my SQL Server Express problem. I have a database that was created in VWD Express 2005, that is currently in C:web projectsproject nameApp data...etc. I have been able to connect to and use the database with an application that I am building as a learning exercise, ( I'm a complete newbie to .NET and SQL Server) but now I can't connect to the database from SQL Server manager.
I have tried attaching the file which has worked a few times, but now that won't work either. I keep getting a message that the file can't be found or I do not have sufficient permissions to access it. I can connnect to the file fine from within VWD, but because of the above problem I can't now run the application (it throws an exception).
I suspect that I've got some of the basic configuration settings wrong, but I really don't know where to start looking. Below is an example of one of the messages I've been getting
Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum)
CREATE FILE encountered operating system error 32(error not found) while attempting to open or create the physical file 'C:InetpubwwwrootBalloonShopApp_DataBalloonShop.mdf'. (.Net SqlClient Data Provider)
Any help would be very gratefully recieved
regards
jon
View 7 Replies
View Related
Jan 4, 2006
When attaching a database that was detached from another SQL Server instance(copied raw .mdf and ldf files)..
I got the error message below:
Error 602: Could not find row in sysindexes for database ID 25, object ID 1,
index ID 1. Run DBCC CHECKTABLE on sysindexes.
how can i solve this problem. i am using SQL Server 2000
Thanks and Regards
View 4 Replies
View Related
Aug 4, 2006
I'm trying to attach a database to sql express with the following code from the management tool. I keep getting an error message. An someone explain what I'm doing wrong.
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near '<'.
IF NOT EXISTS(
SELECT *
FROM sys.databases
WHERE name = N'<northwind.mdb, I4V0Y6SQLEXPRESS, northwind>'
)
CREATE DATABASE <database_name, sysname, your_database_name>
ON PRIMARY (FILENAME = '<c:my documentsmy websmyweb3,,C:Program filesMicrosoft SQL ServerMSSQL.1MSSQLDataorthwind.MDF>')
FOR ATTACH
GO
Ira
View 1 Replies
View Related
Apr 14, 2007
Howdy Folks,
I have a site on WS2003, IIS 6 installed on c:.
I put the site in a folder on d:. Nothing else is on d: except the web site.
I added a new website in IIS and pointed to the site on d:.
Using the default connectionString in machine.config, I am unable to connect to ASPNETDB.MDF. Therefors, I can not log in.
In SQL Server Management Studio Express, I attached ASPNETDB.MDF. I then am able to log in.
Does ASPNETDB.MDF have to be manually attched like this when the web site is located on a drive othr than where IIS is installed and running?
Thanks
View 6 Replies
View Related
Sep 19, 2007
Hi
I need your help in attaching an .mdf database (Created in SQL Server 2005 in another computer) to SQL server 2005. I tried the original way (right click>attache), but all I get is the following:
View 9 Replies
View Related
Jun 2, 2006
hello, (this was originally posted in Administration Forum)
I am helping out with a disaster recovery of a database and i was given 4 files. 2 MDF and 2 LDF files. When I try to attach the files to SQL Server I recieve this err msg:
Server: Msg 823, Level 24, State 6, Line 1
I/O error (torn page) detected during read at offset 0000000000000000 in file 'E:chivirtualGPS0Dat.mdf'.
Connection Broken
I then tried many other combinations hoping something would work --> tried individual files, just data files, tried to create a new DB and then switching/replacing out with the files i needed...etc, nothing seems to work for me. The people I am trying to help out do NOT have backups.
Any thoughts would be appreciated. thanks...
View 7 Replies
View Related
Dec 6, 2006
I was getting following error while creating a database or attaching a database to sql server 2005
"The file <<*.mdf>> is compressed but does not reside in a read-only database or filegroup.."
In this scenario, if you try sp_attach_db procedure, you get following error:
Msg 5118, Level 16, State 1, Line 1
After
little bit of troubleshooting, I found this was happening because of a
folder option (of the folder where database file reside (in case of
attach) or being created (in case of create)).
Go to folder
properties, General Tab, click on Advanced button,check "Compress or
Encrypt attributes" section. If the first option (Compress contents to
save disk space) is checked, you get that error. Uncheck it to fix that
problem.
View 1 Replies
View Related
May 20, 2008
Hi all,
I'm trying to attach a database file and it's associated database log file to SQL Server. However I am using the 'SQLDataRoot' value from the registry to determine the absolute path to the DB file and DB log file. Like so...
USE [master]
DECLARE @RC int
/* read path to SQL Server Express Data directory from registry */
DECLARE @sql_server_data_dir sysname
EXEC @RC = master..xp_regread N'HKEY_LOCAL_MACHINE',N'SOFTWAREMicrosoftMicrosoft SQL ServerMSSQL.1Setup',N'SQLDataRoot', @sql_server_data_dir OUTPUT
SET @sql_server_data_dir = @sql_server_data_dir + N'Data'
CREATE DATABASE [PROJECT_DB] ON
(FILENAME = '''' + @sql_server_data_dir + 'PROJECT_DB.mdf'''),
(FILENAME = '''' + @sql_server_data_dir + 'PROJECT_DB_log.ldf''') FOR ATTACH;
GO
I have also tried using the sp_attach_db stored procedure as follows
EXEC @RC = dbo.sp_attach_db 'PROJECT_DB',
'''' + @sql_server_data_dir + 'PROJECT_DB.mdf''',
'''' + @sql_server_data_dir + 'PROJECT_DB_log.ldf'''
They both the error:
Msg 102, Level 15, State 1, Line 18
Incorrect syntax near '+'.
The quotes in the calls are single quotes not double quotes in case someone queries that. Thank you.
Regards,
Paul
View 3 Replies
View Related
Mar 22, 2008
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 in Visual Web Developer? Is there a stored proc that I can use to detach from the SQL Server 2005 environment after I have made a database and attach this to my project in VWD in one step?
-thanks in advance
View 4 Replies
View Related
Dec 27, 2007
If I create a website in VWD express and create a database in the APP_DATA folder it works great. Then if I attach it in SQL Management Studio, when I go back to opening the website I get MyMachineaspnet can not log into database. Even if I copy the database.mdf file of a working site to a different folder, rename it, attach it. The original website fails to open the original database. With out changing anything. If it's a DNN website it returns Website currently unavalable. After this happens I can in VWD open and see the tables in the database. I think databases created in the APP_DATA folder in VWD are "User Instances" I don't normally see them in SQL management Studio. Something about the Studio breaks them.
This is getting old real quick so PLEASE tell me what am missing here. Thanks
-KK
View 2 Replies
View Related
Feb 6, 2008
Hi,
I m going to attach my databse file to newly installed sqlserver 2000 personel eddition. But when I click the ok button (right click on the database> alltasks> attachdatabase> ). I found the error like
Error 602: Could not find row in sysindexes for database ID 7, Object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.
Can anyone tell me how can I do this to attach database.
Navi
View 3 Replies
View Related
Nov 29, 2006
Dear all,
I recive a error when i attaching a database in sqlserver 2000. The error is :-
An exception occurred while executing a T-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Could not find row in sysindex for databases ID 12, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexs.
Could not open new database 'ABC'. Create Database is aborted. (Microsoft SQL Server, Error: 602)
View 5 Replies
View Related
Oct 14, 2006
Hello Everyone,
I am very new to SQL and just completed an install of SQL 2005 Express. After install, I downloaded the Adventure Works database and attempted to attach through both the Object Browser (right-click 'Databases'--->'Attach') and by running the script that is located on the SQL download page where I got the Adventure Works db.
Here's the error that I get:
"Could not find row in sysindexes for database ID 8, object ID 1, Index ID 1. Run DBCC CHECKTABLE on sysindexes."
I have attempted to go through the help files, but unfortunately the above message is too cryptic for me and I have no idea what it's telling me.
Can someone help?
Thanks!!
View 6 Replies
View Related