Sunday, February 12, 2012

attaching a database in SQL 2005 Express

I am trying to following the instructions in the online books to attached th
e
sample northwnd.mdf database to an instance of sql 2005 express. Here are th
e
instructions from online books:
USE [master]
GO
CREATE DATABASE [database_name] ON
( FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Data\<database name>.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Data\<database name>.ldf' )
FOR ATTACH ;
GO
Where database_name is the name of the database you want to attach, FileName
is the path and filename of the database file and the log file, and FOR
ATTACH specifies that the database is created by attaching an existing set o
f
operating system files.
Apparently I am not substituting the right values in place of
"database_name" and/or "FileName" because I keep getting an error. See below
for what I am typing in and the error that I receive. What am I doing wrong?
1> CREATE DATABASE [northwnd]
2> ( northwnd.mdf = N'C:\sql server 2000 sample databases\northwnd.mdf' ),
3> ( northwnd.ldf = N'C:\sql server 2000 sample databases\northwnd.ldf' )
4> FOR ATTACH ;
5> go
Msg 102, Level 15, State 1, Server CANDACE\SQLEXPRESS, Line 2
Incorrect syntax near 'northwnd'.
1>The first thing I noticed was that the ON was missing. The second
thing was that the keyword FILENAME had been replaced with the logical
file name.
Roy
On Fri, 1 Dec 2006 06:24:00 -0800, Candace
<Candace@.discussions.microsoft.com> wrote:

>I am trying to following the instructions in the online books to attached t
he
>sample northwnd.mdf database to an instance of sql 2005 express. Here are t
he
>instructions from online books:
>USE [master]
>GO
>CREATE DATABASE [database_name] ON
>( FILENAME = N'C:\Program Files\Microsoft SQL
>Server\MSSQL.1\MSSQL\Data\<database name>.mdf' ),
>( FILENAME = N'C:\Program Files\Microsoft SQL
>Server\MSSQL.1\MSSQL\Data\<database name>.ldf' )
> FOR ATTACH ;
>GO
>
>Where database_name is the name of the database you want to attach, FileNam
e
>is the path and filename of the database file and the log file, and FOR
>ATTACH specifies that the database is created by attaching an existing set
of
>operating system files.
>
>Apparently I am not substituting the right values in place of
>"database_name" and/or "FileName" because I keep getting an error. See belo
w
>for what I am typing in and the error that I receive. What am I doing wrong
?
>1> CREATE DATABASE [northwnd]
>2> ( northwnd.mdf = N'C:\sql server 2000 sample databases\northwnd.mdf' ),
>3> ( northwnd.ldf = N'C:\sql server 2000 sample databases\northwnd.ldf' )
>4> FOR ATTACH ;
>5> go
>Msg 102, Level 15, State 1, Server CANDACE\SQLEXPRESS, Line 2
>Incorrect syntax near 'northwnd'.
>1>|||One thing I see is that you are missing the word ON after the database name.
Also, you should
specify the word FILENAME, not substitute it toe something else. Try below:
CREATE DATABASE [northwnd] ON
( FILENAME = N'C:\sql server 2000 sample databases\northwnd.mdf' ),
( FILENAME = N'C:\sql server 2000 sample databases\northwnd.ldf' )
FOR ATTACH ;
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Candace" <Candace@.discussions.microsoft.com> wrote in message
news:C65CAD32-150B-4534-8E4F-A4A6B8267A00@.microsoft.com...
>I am trying to following the instructions in the online books to attached t
he
> sample northwnd.mdf database to an instance of sql 2005 express. Here are
the
> instructions from online books:
> USE [master]
> GO
> CREATE DATABASE [database_name] ON
> ( FILENAME = N'C:\Program Files\Microsoft SQL
> Server\MSSQL.1\MSSQL\Data\<database name>.mdf' ),
> ( FILENAME = N'C:\Program Files\Microsoft SQL
> Server\MSSQL.1\MSSQL\Data\<database name>.ldf' )
> FOR ATTACH ;
> GO
>
> Where database_name is the name of the database you want to attach, FileNa
me
> is the path and filename of the database file and the log file, and FOR
> ATTACH specifies that the database is created by attaching an existing set
of
> operating system files.
>
> Apparently I am not substituting the right values in place of
> "database_name" and/or "FileName" because I keep getting an error. See bel
ow
> for what I am typing in and the error that I receive. What am I doing wron
g?
> 1> CREATE DATABASE [northwnd]
> 2> ( northwnd.mdf = N'C:\sql server 2000 sample databases\northwnd.mdf' ),
> 3> ( northwnd.ldf = N'C:\sql server 2000 sample databases\northwnd.ldf' )
> 4> FOR ATTACH ;
> 5> go
> Msg 102, Level 15, State 1, Server CANDACE\SQLEXPRESS, Line 2
> Incorrect syntax near 'northwnd'.
> 1>|||For future reference, the documentation conventions for SQL Server say that
anything is a command syntax in all capital letters is a keyword that must
be included exactly as specified in the syntax. in the example, CREATE,
DATABASE, ON, FILENAME, FOR, and ATTACH are all keywords which must be
entered as specified.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23sZw2uVFHHA.1080@.TK2MSFTNGP05.phx.gbl...
> One thing I see is that you are missing the word ON after the database
> name. Also, you should specify the word FILENAME, not substitute it toe
> something else. Try below:
>
> CREATE DATABASE [northwnd] ON
> ( FILENAME = N'C:\sql server 2000 sample databases\northwnd.mdf' ),
> ( FILENAME = N'C:\sql server 2000 sample databases\northwnd.ldf' )
> FOR ATTACH ;
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Candace" <Candace@.discussions.microsoft.com> wrote in message
> news:C65CAD32-150B-4534-8E4F-A4A6B8267A00@.microsoft.com...
>

No comments:

Post a Comment