How Do I Use "sp_attach_db" Properly?

Apr 23, 2001

how do i use "sp_attach_db" properly so that i can make a new database with only the .mdf file?

View 2 Replies


ADVERTISEMENT

Sp_attach_db

May 16, 2000

Can anyone spread any light on the following.
I've created a database of 2 tables which exists over 2 drives. I had a 6 Gig log file on one drive and a 1 Gig log file on the other so I used sp_detach_db to detach it. I then deleted the log files and attempted to sp_attach_db with the following:
"sp_attach_db @dbname =N'cwc_load', @filename1 = N'f:cwc_loadcwc_load_data.mdf', @filename2 = N'e:cwc_loadcwc_load_data2.mdf'"
which are the locations of the .mdf files.
I get the error messages 5105 and 945 (which cannot be tracked down using either the Microsoft site or on-line help) but the messages are "Device Activation error. The physical file name 'F:cwc_loadcwc_load_log.ldf' may be incorrect"
"Database 'cwc_load' cannot be opened because some of the files cannot be activated"
which to me tends to suggest that the database is looking for the log files (now deleted).
I've tried forcing a new log file I created using the same locations for the mdfs. I've tried using create database cwc_load on primary (filename = 'etc) which gives the same error message, please tell me someone out there has a resolution for this.

View 2 Replies View Related

Sp_attach_db

Aug 6, 2002

As part of moving to SQL2K from SQL7 I'm doing sp_detach_db and sp_attach_db on the source server. For those databases that have multiple .ldf files do I need to add a separate filename= line to the sp_attach_db command for each .ldf, or only reference the original .ldf in a single filename?

Thanks,

AL

P.S. Given that I've done a few databases already, what's the effect of entering only the single filename line if multiple filename lines were required?

View 1 Replies View Related

Sp_attach_db --FAI:LURE -- HELP

Nov 9, 2000

Does SQL Server Agent need to be running in order to execute the
sp_attach_db stored procedure?

I am getting device activation errors while running this stored procedure.
Is there any other way to attach those files back to the SQL Server.

PLEASE HELP

View 1 Replies View Related

Use Sp_attach_db Proc

Nov 15, 2006

I am trying to use sp_attach_db SP.
I have a dadafile and a log file at D:Asset
which I am trying to extract using

EXECUTE sp_attach_db 'Asset',
'D:AssetAsset_data.mdf',
'D:Assetasset_log.ldf'

can any one of u tell where i went wrong
I am getting this errror "Device activation error. The physical file name 'D:AssetaaAsset_data.mdf' may be incorrect."

I am trying to use the database provided from
http://www.trigonblue.com/sp_download.htm#Diagram
to practise stored procedures.

Thanks in advance

View 4 Replies View Related

HELP! Sp_attach_db Doesn't Work!

Sep 20, 2000

I had a SQL Server falure. I rebiuld Master and tried to attach my database
with sp_attach_db? but get an error

Location: pageref.cpp:3931
Expression: rowLog.RowCount () == 1 || pPage->IsEmpty ()
SPID: 10
Process ID: 119

Connection Broken

View 1 Replies View Related

Sp_attach_db And Sort Order

Dec 6, 2001

Hi,

I'm doing some work for a client who has not been backing up
his databases. After a server crash he has been left with
the .MDF and .LDF files. I have managed to successfully
use sp_attach_db on all but two databases. When attempting
to use sp_attach_db I get the following error message :

1> sp_attach_db @dbname = N'CSGDEV', @filename1 = N'e:SQL_DataDirDataCSGDEV_Data.MDF', @filename2 = N'e:SQL_DataDirDataCSGDEV_Log.LDF'
2> go
Warning: sort order 51 in database differs from server sort order of 52.
Warning: Unicode comparison flags 196608 in database differs from server
Unicode comparison flags of 196609.
Msg 1816, Level 16, State 1, Server CSGSERVER, Line 1
Could not attach the database because the character set, sort order, or Unicode
collation for the database differs from this server.
Warning: sort order 51 in database differs from server sort order of 52.
Warning: Unicode comparison flags 196608 in database differs from server
Unicode comparison flags of 196609.
Msg 1816, Level 16, State 1, Server CSGSERVER, Line 1
Could not attach the database because the character set, sort order, or Unicode
collation for the database differs from this server.

I'd appreciate any ideas. I'm not a SQL Server expert (heck, I'm not even
a Windows expert...) as you can probably tell.

Thanks and cheers,
Deeran

View 1 Replies View Related

EXEC Sp_attach_db Have A Error

Feb 2, 2004

I entered the following in the Query Analyzer and got the result shown:

EXEC sp_attach_db @dbname = N'DS2004',
@filename1 = N'd:ds2004_data.mdf',
@filename2 = N'd:ds2004_log.Ldf'

Server: Msg 5172, Level 16, State 15, Line 1
The header for file 'd:ds2004_data.MDF' is not a valid database file header. The PageAudit property is incorrect

I can find nothing about PageAudit property.

What is it and how do I need to modify the command?

Many thanks

View 2 Replies View Related

Clearness Needed In Sp_attach_db

Jul 20, 2005

HiWith the sql server on line help , The syntax for the sp_attach_db hasthe file name .It is aslo given that max of 16 files can be geven. Iattached a db with a single d.mdf .could u pls tell what r the 16 file types or how a db can be attachedwith 16 files.With thanks

View 1 Replies View Related

Sp_attach_db And Security With Windows Group

Nov 12, 2003

Hello,

We use local server windows groups to allow or disallow use of our SQL databases. We are now being asked to move off of our current server. My thoughts are to dettach and attach the database. What is going to happen to all my permissions based on the user groups of our old server? I intend to create the same group names on the new server but they will be newservergroupname as opposed to oldservergroupname. Is it just a case of scripting the database user, roles and object level permissions an manually changing oldserver to newserver?

View 3 Replies View Related

[EXTREMELY URGENT] Sp_attach_db Error

Jul 20, 2005

I am attaching a database with 3 data files.When I execute "exe sp_attache_db..." I obtain this error:database 'POINT' cannot be opened because some of the files could not beactivated.I have deleted its LDF file.Usually I detach my db, then I delete transaction log, and reattach 3 datafiles...Now it doesn'work!!!!!!!!!!Someone can help me?Thanks.

View 1 Replies View Related

Secure Database Files For Sp_attach_db

Oct 29, 2007



hi,

My problem is, I am going to ship MSDE with our product. Now the problem is that if some one copies the .MDF and .LDF files and uses "sp_attach_db" to attach the db files to his own server then my database will be exposed to him. I have tried this and it gets exosed. I cant deploy NT Authentication for the database, bcoz if the end user installes Enterprise manager then my database will be exposed to him. Is there any way that i can sequre the LDF and MDF files of my database so that no one can use that with sp_attach_db? I m using MSDE(Sql server 2000).

View 10 Replies View Related

Permission Problems With Sp_attach_db During Installation

Sep 26, 2007



I successfully install SQL Express silently.

Then I try the following


-S .INSTANCE -Q "sp_attach_db 'ATTACH_AS_NAME', 'C:Program FilesAPP_NAMESQLDataAPP_DB.MDF'"

This works...sometimes. But Many times I wll get a permissions error on the folder "C:Program FilesAPP_NAME". If I go and give "Everyone" "Full Permission" to the folder...it works fine.

My questions are:
1) What system users need access (and at what level) to this folder to do an attach? Because obviously giving everyone full access is bad.


2) Is there a better method for deploying a populated database with my application that this?

View 9 Replies View Related

Logins, Object Ownership And Sp_detach_db/sp_attach_db

Apr 4, 2000

Here's one. :)
I have Database A in Server 1 which contains objects (tables and SPs) that are owned by users other than dbo. Then I detach this database from Server 1 using sp_detach_db and attach it to Server2 (sp_attach_db). Even if the same logins exist or are created in Server 2, I still won't be able to access the objects in Database A using these logins. I know that this happens because of different SIDs for the same login names across the 2 servers. So given that I want to achieve this without having to use the Import Wizard or any other method, how do I go around this lil bit of a problem? Any thoughts? :)

Thanks!

View 1 Replies View Related

Sp_attach_db Failed On Mapped Remote Drive

Mar 1, 2001

Hi,all.
I tried to issue:
sp_attach_db pubs,'F:anthonypubs.mdf','F:anthonypubs.ldf'

where the pubs.mdf and pubs.ldf are on a remote mapped drive F:,
I got error:

Server: Msg 5105, Level 16, State 4, Line 1
Device activation error. The physical file name 'f:anthonypubs.ldf' may
be incorrect.

Is attaching a database ONLY supported for local servers ??
What about creating database on remote drive? (I have same error msg back)
Thx
Anthony

View 1 Replies View Related

Device Activation Error On Sp_attach_db To Local Drive

Apr 25, 2007

Here is the error, I receive:

Msg 5105, Level 16, State 4, Line 1
Device activation error. The physical file name 'L:Program FilesMicrosoft SQL ServerMSSQLLOGTestDB_Log.LDF' may be incorrect.
Device activation error. The physical file name 'L:Program FilesMicrosoft SQL ServerMSSQLLOGTestDB_Log.LDF' may be incorrect.
Msg 5170, Level 16, State 1, Line 1
Cannot create file 'L:Program FilesMicrosoft SQL ServerMSSQLLOGTestDB_log.LDF' because it already exists.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'TestDB'. CREATE DATABASE is aborted.

Here is my attach script:
USE [master]
GO
sp_attach_db @dbname= N'TestDB',
@filename1 = N'S:Program FilesMicrosoft SQL ServerMSSQLDataTestDB.MDF',
@filename2 = N'L:Program FilesMicrosoft SQL ServerMSSQLLOGTestDB_Log.LDF'

This server has a Raid 5 Disk Array partitioned into three Logic Drives C:, S:, L:. Not sure, why the server was configured this way. If I attach the database with the data and log files on the same logical drive, the DB attaches successfully. When I try to put the data and log files on separate logical drives, it fails. Issue seems to be with the drive partitioning. Any Ideas?

View 4 Replies View Related

How To Properly Use GO, BEGIN, END

Jan 12, 2008

I have writen a small program in a Query window that runs fine if I hilight and run small chuncks. (I have listed the statements with out the clauses so it is more easly viewed here.)

The problem is if I simply execute the Query window I get massive errors that don’t make sence. I am guessing I need some GO and BEGIN/END statements? But I don’t know where I should use them.

I would really appreciate a few pointers so I can just run the Query window.


drop table SourceFile
drop table ReferenceFile

SELECT TOP
INTO SourceFile
FROM

SELECT TOP
INTO ReferenceFile
FROM

-- test data
INSERT ReferenceFile
(AddressCleanedPK, New_First_Name, New_Last_Name, New_Address, Phone, Zip)
values ()
INSERT SourceFile
(AddressCleanedPK, New_First_Name, New_Last_Name, New_Address, Phone, Zip)
values (22)
-- test data


drop table MATCHTEST
SELECT TOP 1 AddressCleanedPK, New_First_Name, New_Last_Name, New_Address, Phone, Zip
INTO MATCHTEST
FROM AddressCleaned_npidata_20050523_20071112

DELETE MATCHTEST

ALTER TABLE MATCHTEST
ADD REF_ML VARCHAR(2)

INSERT MATCHTEST ()
SELECT
FROM ReferenceFile r
inner join SourceFile s
on s.New_Last_Name = r.New_Last_Name

select * from MATCHTEST

View 3 Replies View Related

Deploying IS Properly

Sep 11, 2007



Hi,

How do i deploy IS package properly? can i just copy the .dtsx and assign that in an sql jobs?

thanks a lot

cherriesh

View 3 Replies View Related

How To Build Properly

Jun 30, 2006



Hi,

I'm very new in SSIS. I've created 3 packages in the project. sometimes when i modified the project and save/save-all it, when i tried to build (isn't this used to deploy?), I am being asked by this:

Package 1 has been modified outside the source editor. Do you want to reload it?

When I press on yes, all my modifications were not save. If i answered no, the build process stops. i dunno if this is because the build process is already finished or it was terminated because i chose 'NO'. When i tried to rebuild it again, it will ask me the same question.

What is the proper way to save and build the project? When it says ' do you want to reload it?', does it mean reloading the old copy before modification?

Thanks!

cherrie

View 3 Replies View Related

Order By Not Working Properly

Jan 17, 2007

Hello, i have something like this, i want the annoucements (status = 0) to be on top, then topics with (status = 1) below, then the rest of the topics.
So i tried:
SELECT forum_topics.id, forum_topics.status, forum_topics.username AS starter, forum_topics.subject, forum_topics.closed, forum_topics.answerpostid, forum_topics.views, forum_topics.answers, forum_topics.lastanswer, forum_topics.lastanswerid, forum_topics.created AS started, forum_answer.username, forum_answer.answer, forum_answer.created FROM forum_topics LEFT OUTER JOIN forum_answer ON forum_answer.id = forum_topics.lastanswerid WHERE (boardid = @ID OR boardid = 0) ORDER BY (status) ASC, (created) ASC
Problem is that they are not sorted diffrently, when i change the (created) ASC to (created) DESC i get the same result and the rows are not sorted, they only get sorted by status so i have status=0 at the top, then status=1 then the rest. How do i get them to be sorted first by status ASC then by created ASC/DESC?
Patrick

View 1 Replies View Related

MDAC 2.6 SP1 Not Installing Properly

May 22, 2002

I installed MDAC 2.6 SP1 on my 2000 machine in order to get SQL server 7.0 to work properly on my machine. I'm trying to get installed on server which is on NT 4.0 SP6 so that when I save a DTS package on my 2000 machine and run it on the server it doesn't get the error client access ODBC driver not capable. I intalled MDAC 2.6 SP1 on the server but it doesn't look like its updating it. The install goes fine. I reboot but when I go into the ODBC connections and look at the driver for the client acceess it still has version 6.00.00.05 while my 2000 machine says 6.00.07.00

Any ideas on why its not updating. Can I just take the DWBODBC.DLL from my machine and copy it to the server?

View 1 Replies View Related

SQL Agent Not Starting Properly

Sep 28, 1999

We have SQL Server 7.0 running on an NT 4.0 sp5 box. Whenever we stop the SQL Server Service, we get the message that SQL Agent will also be stopped. If we do this, all the services seem to stop fine, but when we try to start the SQL Server Agent Service back up, it won't let us. In order for it to restart, we have to reboot the server so that it starts 'automatically'. Does anyone have any ideas as to why this is?

View 1 Replies View Related

Float Value Doesn't Come Up Properly...

Jun 19, 2001

I define one of my columns as FLOAT. Some of the values are negative and positive with precision 8 or 12. When I run updates against that column and then check the data all values are 0.

Any idea why?? I appreciate it.

Thanks,


David

View 1 Replies View Related

Trigger Not Inserting Properly

May 3, 2004

I have the following trigger that will insert the correctly if none of the items in the #tempKCS exist in the destination table. However if one of the items in the #tempKCS table do exist in the Sales table then the insert does not execute for the other itmes in the #temoKCS list that are not already listed in the Sales Table. Below is the trigger. Tell me where I am making my mistake. Thanks

CREATE TRIGGER [Insert_KCSales] on [dbo].[Reclines]
FOR INSERT, UPDATE
AS

SELECT KitItemSum.Date, Kits.KitItemNo AS ItemNo, (Kits.Quantity * KitItemSum.QtySold) As QtySold, ((Kits.[Percentage]/100) * KitItemSum.AmtSold) AS AmtSold, KitItemSum.Division, 0 AS QtyReturned, 0 AS AmtReturned Into #TempKCS
FROM (SELECT Summary.Recdate AS [Date], Summary.ItemNo, Sum(Summary.Qty) AS QtySold, SUM((Summary.Amount-Summary.DiscAmt)) AS AmtSold, Summary.Division
FROM (SELECT DISTINCT R.Recno, R.Recdate,I.RecLineNo, I.ItemNo, I.Qty, I.Amount, I.DiscAmt, I.Division FROM Inserted I
INNER JOIN Kits K ON I.ItemNo = K.MasterItemNo INNER JOIN Receipt R ON I.RecNo = R.RecNo INNER JOIN Items ON I.ItemNo = Items.ItemNo) AS Summary
GROUP BY Summary.RecDate, Summary.ItemNo, Summary.Division) AS KitItemSum INNER JOIN Kits ON KitItemSum.ItemNo = Kits.MasterItemNo;

INSERT INTO Sales ([Date], ItemNo, Division, QtySold, AmtSold, Qtyreturned, AmtReturned)
SELECT [Date], ItemNo, Division, QtySold, Amtsold, Qtyreturned, Amtreturned
FROM #TempKCS
WHERE NOT EXISTS (SELECT S.[Date], S.[ItemNo] FROM Sales S INNER JOIN #TempKCS KCS on S.ItemNo = KCS.ItemNo AND S.[Date] = KCS.[Date]);

View 1 Replies View Related

SQL Server Is Not Working Properly

Apr 21, 2008

Hello friends, I have developed an ASP.NET 2.0 application. The problem is that the IIS server returns the next error:

SQL Server does not allow remote connections

Sometimes returns:

SQL Server does not exists.

My question is if there is any known bug with ASP.NET and SQL Server. My sql server have activated the Remote Connections (its working properly on other web page).

Its a problem of the number of connections??
Its a problem ofbad configuration??
Its a IIS problem??

Please bring me some help.

View 8 Replies View Related

Report Service Not Act Properly

Jul 18, 2007

Hi,

We installed SQL Server 2005 on windows 2000 with IIS 5. After installation, I can see report manager using http://localhost/reports. But I can only the top part. There's no My Reports or anything, just "Home / My subscriptions / Help".

Is there anything wrong and how to fix it?

Any help would be appreciated.

Thanks

View 5 Replies View Related

SQL Command Not Properly Ended

Mar 11, 2008

Hi i given my query here. in that joings betweens tables is correct, but i am getting the following error
ora-00933 sql command not properly ended
can we have exists function inside if condition??

select distinct loc.authorization from account acct, location loc, iom_order iom
where loc.location_id = acct.location_id and acct.account_id = iom.account_id and iom.iom_order_id =140

if(loc.authorization is null and exists(
select distinct line.INTRALATA_PIC_FREEZE ,line.INTERLATA_PIC_FREEZE
from line line, iom_order iom, activity act
where ((line.INTRALATA_PIC_FREEZE='F' or line.INTERLATA_PIC_FREEZE='F')and line.line_id = act.component_id and act.component = 23 and act.iom_order_id = 140)
union all
select distinct trunk.INTRALATA_PIC_FREEZE ,trunk.INTERLATA_PIC_FREEZE
from trunk trunk, activity act
where ( (trunk.INTRALATA_PIC_FREEZE='F' or trunk.INTERLATA_PIC_FREEZE='F')andtrunk.trunk_id = act.component_id and act.component = 25 and act.iom_order_id = 140)
select distinct rcf.INTRALATA_PIC_FREEZE ,rcf.INTERLATA_PIC_FREEZE
from remote_call_fwd rcf, activity act
where((rcf.INTRALATA_PIC_FREEZE='F' or rcf.INTERLATA_PIC_FREEZE='F')and rcf.remote_call_fwd_id = act.component_id and act.component = 24 and act.iom_order_id = 140)
select distinct tsg.INTRALATA_PIC_FREEZE ,tsg.INTERLATA_PIC_FREEZE
from nodal_tsg tsg, activity act
where ((tsg..INTRALATA_PIC_FREEZE='F' or tsg.INTERLATA_PIC_FREEZE='F')and tsg.nodal_tsg_id = act.component_id and act.component = 5 and act.iom_order_id = 140))) Then
select distinct loc.authorization from order2misc o2m, location loc, iom_order iom where loc.location_id =
o2m.serv_loc_id and iom.iom_order_id =140
else
select distinct loc.authorization from account acct, location loc, iom_order iom
where loc.location_id = acct.location_id and acct.account_id = iom.account_id and iom.iom_order_id =140
end if;

View 1 Replies View Related

How To Properly Restore Transaction Log

Jul 20, 2005

Hi,Currently, I am on SQL2000 SP3 and Windows 2003.I am trying to restore the full database backup and transaction logbackup on the development server. The full database restore is not aproblem, but the transaction log restore happened during the day is.Everytime when I try to compare the transaction in the database(select the last update date from one of my table as a benchmark, thenbackup the transaction log for restore) to the development db with therestored transaction log, I got none of the transaction from the logbackup.What did I do wrong? Is my concept about using the transaction logrestore wrong?Thanks in advance.

View 4 Replies View Related

Help Joining Tables Properly.

Jul 20, 2005

I have about 7 tables I need to join, but am having a lot ofdifficulty with the joins, that I need some help on.I'll provide the details of four tables to illustrate the scenario.I have one table called Product, which contains a complete list ofproducts.I have another table called Date, which contains a complete list ofdates.I have a table called sales, which contains Product, date and Qty.I have a table called Purchases which contains product, date and qty.I want to link my Purchases and sales tables to my Product and datetables.On each row I want product from the Product table, Date from the datetable, Sales Qty from the sales table and Purchases Qty from thePurchases table.I've been messing around with full outer, inner joins etc, but can'tget it right.All help greatfull.Regards,Ciarán

View 5 Replies View Related

SP2 Not Installed Properly.(Urgent Pls Help)!!!!

Aug 31, 2007

Hi,

I have 2 servers running in a clustered mode(active/active). In which we installed SP2 on peak production time but somehow it resulted in failure i.e it installed partially and sql server is unstable as of now. I'd like to know if it would be fine to restart the server without full installation of SP2 and what could be the implications of a server restart in such a scenario.
Pls help urgent!!!!!!!

View 1 Replies View Related

Ragged Right Not Working Properly

Dec 25, 2007



Hi,
I am exporting a table to a fixed width flat file using "Ragged Right" format. Though i specify carriage return for the last column, the text file is not taking it up.

I am doing the following for connection
cmFlatFile.properties("Format").SetValue(cmFlatFile,"RaggedRight")
cmFlatFile.properties("RowDelimiter").SetValue(cmFlatFile,vbCrLf)

and while adding the column i am setting up the width as follows

vColumns = flatFileDestination.InputCollection(0).GetVirutalInput().VirtualInputColumnCollection

For cols = 0 to vColumns.Count -1
Dim col As IDTSConnectionManagerFlatFileColumn90 = ff.Columns.Add()
if cols = vColumns.Count - 1 Then
col.ColumnDelimiter = vbCrLf
end if
cols.ColumnType = "FixedWidth"
cols.Columnwidth = 20
......
Next cols

Still the rows are exported next to each other just like when we use FixedWidth.

View 4 Replies View Related

SQL Configuration Does Not Work Properly

Jul 17, 2007

Hi,



I've my SSIS Packages, having multiple Configuration stored in SQL Server Table named [SSIS Configurations].

And it's devloped on BHUDEV Server ON Devlopmentdb Database. So durring development Default Cofigurations are set for BHUDEV Server.



Problem is that when I install my Package on SQL Server on different Server for example JOHN, and now my database is ProductionDB and [SSIS Configurations] table will be on ProductionDB database. And I've made required changes in [SSIS Configurations] table. So when I run the Package even then it picks configuration information from BHUDEV.Developmentdb.dbo.[SSIS Configurations] table. That's my problem.



But If when during execution time, I change the connection information then it works fine.



Please Help!



Bhudev

View 6 Replies View Related

Cannot De-install SQL 2000 Properly

Sep 5, 2007

Hi,
Long story, Ihad SQL 2000 happily installed and running for a long time. Attempted to load SQL 2005 alongside, but in retrospect see that I used the same install directory as SQL 2000. Found that the SQL 2000 databases still ran, in that I was able to run applications that rely on them. Enterprise manager ans Query Analyzer are still in the start/program list, but when I try to open them they say that the DSN isn't there, and the odbc driver is missing. Also if I try to configure the system SQL DSN in ODBC datasources I get the same message. I guess the SQL 2005 install has scrambled the ODBC setup.Tried deinstalling SQL 2005, but the problem persists. Tried reloading mdac-typ, same problem. Tried reinstalling SQL2000, same problem. Tried fully deinstalling SQL2000 from Add/remove program, said it completed, but the shortcuts are still there, the applications that use the db's still work, only it no longer appears in Add/Remove programs.
Is there a command line string to manually remove it, or where do I go to repair my mdac, or is this what I actually want to do?

Thanks in advance

Hugh Esler

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved