Showing posts with label exec. Show all posts
Showing posts with label exec. Show all posts

Sunday, February 19, 2012

Attachment file is invalid.

Hello,

I have a stored procedure with this syntax

declare @.filename varchar(100)

set @.filename='c:/A.pdf'

EXEC msdb.dbo.sp_send_dbmail

@.profile_name =@.p_profile

@.recipients = @.p_address,

@.body = @.p_body,

@.subject = @.p_subject,

@.file_attachments = @.filename

but when I execute it i have an error

Attachment file c:/A.pdf is invalid.

What's happen? Thanks in advance

hi,

It seems you are trying to load the file from invalid path. Change to

@.filename='C:\A.pdf' instead of 'c:/A.pdf'

Also make sure that A.pdf file is availed in C Drive.

|||Moving to the Transact-SQL forum.

Thursday, February 16, 2012

Attaching SQL Database in 2005 from CD-ROM

Hi:
I am trying to attach a database on a CD-ROM using the following command
exec sp_attach_db dbname='dbname',
filename1='d:\dbname.mdf',
filename2='d:\dbname.ldf'
and I am getting the following error
Msg 3415, Level 16, State 1, Line 1
Database 'dbname' cannot be upgraded because it is read-only or has
read-only files. Make the database or files writeable, and rerun recovery.
Any Help would be appreciated.
TIA
-sriniIts working on SQL 2000 Server. I am wondering is there a work-around for
SQL 2005.
-srini
"srini" wrote:
> Hi:
> I am trying to attach a database on a CD-ROM using the following command
> exec sp_attach_db dbname='dbname',
> filename1='d:\dbname.mdf',
> filename2='d:\dbname.ldf'
> and I am getting the following error
> Msg 3415, Level 16, State 1, Line 1
> Database 'dbname' cannot be upgraded because it is read-only or has
> read-only files. Make the database or files writeable, and rerun recovery.
>
> Any Help would be appreciated.
> TIA
> -srini|||SQL needs upgradte the db and the cdrom is read only,upgrade from hard disk
and then save to cdrom
"srini" <srini@.discussions.microsoft.com> escribió en el mensaje
news:A8B27EC6-2370-4596-8FF2-E505147BB62D@.microsoft.com...
> Hi:
> I am trying to attach a database on a CD-ROM using the following command
> exec sp_attach_db dbname='dbname',
> filename1='d:\dbname.mdf',
> filename2='d:\dbname.ldf'
> and I am getting the following error
> Msg 3415, Level 16, State 1, Line 1
> Database 'dbname' cannot be upgraded because it is read-only or has
> read-only files. Make the database or files writeable, and rerun recovery.
>
> Any Help would be appreciated.
> TIA
> -srini|||Look at this page from BOL:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/fd717bec-b389-4b1e-936c-a4ccf75dba77.htm
--
Geoff N. Hiten
Senior Database Administrator
Microsoft SQL Server MVP
"srini" <srini@.discussions.microsoft.com> wrote in message
news:A8B27EC6-2370-4596-8FF2-E505147BB62D@.microsoft.com...
> Hi:
> I am trying to attach a database on a CD-ROM using the following command
> exec sp_attach_db dbname='dbname',
> filename1='d:\dbname.mdf',
> filename2='d:\dbname.ldf'
> and I am getting the following error
> Msg 3415, Level 16, State 1, Line 1
> Database 'dbname' cannot be upgraded because it is read-only or has
> read-only files. Make the database or files writeable, and rerun recovery.
>
> Any Help would be appreciated.
> TIA
> -srini|||Thanks Geoff for a quick reply.
I read and tried the same it works. Thanks a lot.
Just in case if some one, needs step by step guidelines
Step1:
EXEC sp_create_removable 'exportdb',
'exportdbsys',
'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\exportdbsys.mdf', 2,
'exportdblog',
'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\exportdblog.ldf', 2,
'exportdbdata',
'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\DATA\exportdbdata.ndf', 2
Step2:
Exported all objects that I wanted into this db through context menu optoin
"Export "
Step3:
sp_certify_removable exportdb
Step4:
Took the db offline.
Step5:
Copied the files on CD-ROM
Step6:
Deleted exportdb
Step7:
Attached the exportdb as exportdb1 as follows
sp_attach_db @.dbname = 'exportdb1',
@.filename1 = 'd:\exportdbsys.mdf',
@.filename2 = 'd:\exportdbdata.ndf',
@.filename3 = 'd:\exportdblog.ldf'
step8:
Verified the db works with simple select statement.
-srini
"Geoff N. Hiten" wrote:
> Look at this page from BOL:
> ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/fd717bec-b389-4b1e-936c-a4ccf75dba77.htm
> --
> Geoff N. Hiten
> Senior Database Administrator
> Microsoft SQL Server MVP
>
> "srini" <srini@.discussions.microsoft.com> wrote in message
> news:A8B27EC6-2370-4596-8FF2-E505147BB62D@.microsoft.com...
> > Hi:
> >
> > I am trying to attach a database on a CD-ROM using the following command
> >
> > exec sp_attach_db dbname='dbname',
> > filename1='d:\dbname.mdf',
> > filename2='d:\dbname.ldf'
> >
> > and I am getting the following error
> >
> > Msg 3415, Level 16, State 1, Line 1
> > Database 'dbname' cannot be upgraded because it is read-only or has
> > read-only files. Make the database or files writeable, and rerun recovery.
> >
> >
> > Any Help would be appreciated.
> >
> > TIA
> > -srini
>|||Thanks Luis Tarzia.
My requirement is to use the database on CD-ROM as read-only database and I
want to be able to attach the db to any SQL 2005 and start using the same.
-srini
"Luis Tarzia" wrote:
> SQL needs upgradte the db and the cdrom is read only,upgrade from hard disk
> and then save to cdrom
> "srini" <srini@.discussions.microsoft.com> escribió en el mensaje
> news:A8B27EC6-2370-4596-8FF2-E505147BB62D@.microsoft.com...
> > Hi:
> >
> > I am trying to attach a database on a CD-ROM using the following command
> >
> > exec sp_attach_db dbname='dbname',
> > filename1='d:\dbname.mdf',
> > filename2='d:\dbname.ldf'
> >
> > and I am getting the following error
> >
> > Msg 3415, Level 16, State 1, Line 1
> > Database 'dbname' cannot be upgraded because it is read-only or has
> > read-only files. Make the database or files writeable, and rerun recovery.
> >
> >
> > Any Help would be appreciated.
> >
> > TIA
> > -srini
>
>

Monday, February 13, 2012

Attaching and Detaching Databases

in the BOL I have read the "Attaching and Detaching Databases"
in the query analyzer (pointing to the master db) I run (as sa)
EXEC sp_detach_db 'Mydb', 'true'
I got this message which is not covered.
Server: Msg 3702, Level 16, State 1, Line 1
Cannot drop the database 'mydb' because it is currently in use.
DBCC execution completed. If DBCC printed error messages, contact your
system administrator.
The database has no connections to it other than the Enterprise manager.
what am I missing.Do you have the database open (i.e. browsing the objects) in Enterprise
Manager? Is the database open in Query Analyzer and "collapsed". If so,
there's your connection.
You can also run sp_who to find out what connections are currently attached.
-Morgan
"BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
news:u5WMY2lcDHA.2112@.TK2MSFTNGP10.phx.gbl...
> in the BOL I have read the "Attaching and Detaching Databases"
> in the query analyzer (pointing to the master db) I run (as sa)
> EXEC sp_detach_db 'Mydb', 'true'
> I got this message which is not covered.
> Server: Msg 3702, Level 16, State 1, Line 1
> Cannot drop the database 'mydb' because it is currently in use.
> DBCC execution completed. If DBCC printed error messages, contact your
> system administrator.
>
> The database has no connections to it other than the Enterprise manager.
> what am I missing.
>|||Hi,
>>other than the Enterprise manager.
Even that is a connection.Try sp_who and make sure to kill the spids
accessing the database.
--
Dinesh.
SQL Server FAQ at
http://www.tkdinesh.com
"BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
news:u5WMY2lcDHA.2112@.TK2MSFTNGP10.phx.gbl...
> in the BOL I have read the "Attaching and Detaching Databases"
> in the query analyzer (pointing to the master db) I run (as sa)
> EXEC sp_detach_db 'Mydb', 'true'
> I got this message which is not covered.
> Server: Msg 3702, Level 16, State 1, Line 1
> Cannot drop the database 'mydb' because it is currently in use.
> DBCC execution completed. If DBCC printed error messages, contact your
> system administrator.
>
> The database has no connections to it other than the Enterprise manager.
> what am I missing.
>|||thanks for you answers:
Does not sp_who show the connections to the server?
do I have to remove all connection to the server just to move one DB?
This seems illogical sense the default is always logged in.
I looked at the sp_detach_db and it seems the error is being generated in
the
DBCC DETACHDB
which I don't know enough about, to go poking around.
I looked up in the BOL and it does not show in SQL 7.0 version.
in looking at
DROP DATABASE (T-SQL)
it mentions something about offline.
"BJ Freeman" <bj_newsgroups@.free-man.net> wrote in message
news:u5WMY2lcDHA.2112@.TK2MSFTNGP10.phx.gbl...
> in the BOL I have read the "Attaching and Detaching Databases"
> in the query analyzer (pointing to the master db) I run (as sa)
> EXEC sp_detach_db 'Mydb', 'true'
> I got this message which is not covered.
> Server: Msg 3702, Level 16, State 1, Line 1
> Cannot drop the database 'mydb' because it is currently in use.
> DBCC execution completed. If DBCC printed error messages, contact your
> system administrator.
>
> The database has no connections to it other than the Enterprise manager.
> what am I missing.
>

Sunday, February 12, 2012

Attaching a Database

I need some help, I am new at MSDE. I know the command to use but I am not
so sure how to use it. I tried to 'EXEC sp_attach_db @.dbname = kennel' at
the command prompt. Can someone point me in the right direction please.
Norm Bohana
hi,
nbohana wrote:
> I need some help, I am new at MSDE. I know the command to use but I
> am not so sure how to use it. I tried to 'EXEC sp_attach_db @.dbname
> = kennel' at the command prompt. Can someone point me in the right
> direction please.
you have to provide the full command in the correct syntax , that's to say
EXEC sp_attach_db @.dbname = N'pubs',
@.filename1 = N'c:\Program Files\Microsoft SQL
Server\MSSQL\Data\pubs.mdf',
@.filename2 = N'c:\Program Files\Microsoft SQL
Server\MSSQL\Data\pubs_log.ldf'
specifying all files part of the database it self..
http://msdn.microsoft.com/library/de...ae-az_52oy.asp
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Thank you, can I issue this command at the command line? I tried and windows
could not find the 'EXEC' command? Please advise. Again thank you.
Norm Bohana
"Andrea Montanari" wrote:

> hi,
> nbohana wrote:
> you have to provide the full command in the correct syntax , that's to say
> EXEC sp_attach_db @.dbname = N'pubs',
> @.filename1 = N'c:\Program Files\Microsoft SQL
> Server\MSSQL\Data\pubs.mdf',
> @.filename2 = N'c:\Program Files\Microsoft SQL
> Server\MSSQL\Data\pubs_log.ldf'
> specifying all files part of the database it self..
> http://msdn.microsoft.com/library/de...ae-az_52oy.asp
> --
> Andrea Montanari (Microsoft MVP - SQL Server)
> http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
> DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>
>
|||hi,
nbohana wrote:
> Thank you, can I issue this command at the command line? I tried and
> windows could not find the 'EXEC' command? Please advise. Again
> thank you.
the statement you have to execute is not a DOC command, sorry... you have to
execute it via a tool enabled to connect to and perform such tasks to SQL
Server/MSDE...
MSDE provides a command line tool, oSql.exe, you can use..
please have a look at
http://support.microsoft.com/default...;EN-US;q325003 for some
basic info about oSql.exe...
when you are logged in you will be prompted with a prompt like
1>
just type the statement and at very last type GO (and hit return key) so
that you have something like
1>EXEC sp_attach_db @.dbname = N'pubs',
2>@.filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf',
3>@.filename2 = N'c:\Program Files\Microsoft SQL
Server\MSSQL\Data\pubs_log.ldf'
4>GO
and the command will be executed...
further info about oSql and it's synopsis can be found at
http://msdn.microsoft.com/library/de..._osql_1wxl.asp
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply