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


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

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 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

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

Stored Proc Question : Why If Exisits...Drop...Create Proc?

Jun 15, 2006

Hi All,Quick question, I have always heard it best practice to check for exist, ifso, drop, then create the proc. I just wanted to know why that's a bestpractice. I am trying to put that theory in place at my work, but they areasking for a good reason to do this before actually implementing. All Icould think of was that so when you're creating a proc you won't get anerror if the procedure already exists, but doesn't it also have to do withCompilation and perhaps Execution. Does anyone have a good argument fordoing stored procs this way? All feedback is appreciated.TIA,~CK

View 3 Replies View Related

ASP Cannot Run Stored Proc Until The Web User Has Run The Proc In Query Analyzer

Feb 23, 2007

I have an ASP that has been working fine for several months, but itsuddenly broke. I wonder if windows update has installed some securitypatch that is causing it.The problem is that I am calling a stored procedure via an ASP(classic, not .NET) , but nothing happens. The procedure doesn't work,and I don't get any error messages.I've tried dropping and re-creating the user and permissions, to noavail. If it was a permissions problem, there would be an errormessage. I trace the calls in Profiler, and it has no complaints. Thedatabase is getting the stored proc call.I finally got it to work again, but this is not a viable solution forour production environment:1. response.write the SQL call to the stored procedure from the ASPand copy the text to the clipboard.2. log in to QueryAnalyzer using the same user as used by the ASP.3. paste and run the SQL call to the stored proc in query analyzer.After I have done this, it not only works in Query Analyzer, but thenthe ASP works too. It continues to work, even after I reboot themachine. This is truly bizzare and has us stumped. My hunch is thatwindows update installed something that has created this issue, but Ihave not been able to track it down.

View 1 Replies View Related

Processing The Resultset Of Another Proc From A Proc

Apr 8, 2004

Is it possible to retrieve the resultset of a stored procedure from another procedure in sql server 2000.
Basically I am calling proc2 from the inside of proc1.
proc2 returns 2 resultsets. I want to process these two resultsets
from within proc1.

If its possible , please provide sample code.

thanks in advance,
Alok.

View 1 Replies View Related

Can You Trace Into A Stored Proc? Also Does RAISERROR Terminate The Stored Proc Execution.

Feb 13, 2008

I am working with a large application and am trying to track down a bug. I believe an error that occurs in the stored procedure isbubbling back up to the application and is causing the application not to run. Don't ask why, but we do not have some of the sourcecode that was used to build the application, so I am not able to trace into the code.
So basically I want to examine the stored procedure. If I run the stored procedure through Query Analyzer, I get the following error message:
Msg 2758, Level 16, State 1, Procedure GetPortalSettings, Line 74RAISERROR could not locate entry for error 60002 in sysmessages.
(1 row(s) affected)
(1 row(s) affected)
I don't know if the error message is sufficient enough to cause the application from not running? Does anyone know? If the RAISERROR occursmdiway through the stored procedure, does the stored procedure terminate execution?
Also, Is there a way to trace into a stored procedure through Query Analyzer?
-------------------------------------------As a side note, below is a small portion of my stored proc where the error is being raised:
SELECT  @PortalPermissionValue = isnull(max(PermissionValue),0)FROM Permission, PermissionType, #GroupsWHERE Permission.ResourceId = @PortalIdAND  Permission.PartyId = #Groups.PartyIdAND Permission.PermissionTypeId = PermissionType.PermissionTypeId
IF @PortalPermissionValue = 0BEGIN RAISERROR (60002, 16, 1) return -3END 
 

View 3 Replies View Related

Resultset Of Proc In Another Proc

Oct 4, 2005

Hello,i want to use the result set from a stored proc in another stored proc, forexample:create stored procedure proc1 (@x int) asdeclare @tbl (y1 int, y2 int)insert into @tbl values(@ * @x, @x * @x * @x)select * from @tblGO--create stored procedure proc2 (@x int) asdeclare @tbl (y1 int, y2 int)while @x > 0 begininsert into @tbl select (exec proc1 @x) <-- this is my problemset @x = @x - 1endselect * from @tblGO--I know i could use output parameters. But i want to know if something ispossible with SQL-Server?thanks,Helmut

View 4 Replies View Related

Calling A Proc From A Proc

Jan 10, 2007

I'm having problems calling my second proc (MyProcedure2) from within anexisting proc. MyProcedure2 does not seeem to fire this way. My code isbelow. Help appreciated.Thanks,TrevorALTER procedure dbo.MyProcedure1(@newsletterid int)ASSET NOCOUNT ON-- Return Subscribersdeclare @howmany intset @howmany=isnull((select count(subscriberid) from mySubscribers wherenewsletterid=@newsletterid),0)update Mynewsletters set status=3,howmany=@howmany wherenewsletterid=@newsletteridselect @howmanyexec MyProcedure2*** Sent via Developersdex http://www.developersdex.com ***

View 4 Replies View Related

Stored Proc - Calling A Remote Stored Proc

Aug 24, 2006

I am having trouble executing a stored procedure on a remote server. On my
local server, I have a linked server setup as follows:
Server1.abcd.myserver.comSQLServer2005,1563

This works fine on my local server:

Select * From [Server1.abcd.myserver.comSQLServer2005,1563].DatabaseName.dbo.TableName

This does not work (Attempting to execute a remote stored proc named 'Data_Add':

Exec [Server1.abcd.myserver.comSQLServer2005,1563].DatabaseName.Data_Add 1,'Hello Moto'

When I attempt to run the above, I get the following error:
Could not locate entry in sysdatabases for database 'Server1.abcd.myserver.comSQLServer2005,1563'.
No entry found with that name. Make sure that the name is entered correctly.

Could anyone shed some light on what I need to do to get this to work?

Thanks - Amos.

View 3 Replies View Related

Calling A Stored Proc From Within Another Stored Proc

Feb 20, 2003

I have seen this done by viewing code done by a SQL expert and would like to learn this myself. Does anyone have any examples that might help.

I guess I should state my question to the forum !

Is there a way to call a stored proc from within another stored proc?

Thanks In Advance.

Tony

View 1 Replies View Related

Stored Proc Calls Another Stored Proc

Jan 13, 2006

Hi all,

I have a stored procedure "uspX" that calls another stored procedure "uspY" and I need to retrieve the return value from uspY and use it within uspX. Does anyone know the syntax for this?

Thanks for your help!
Cat

View 5 Replies View Related

Calling Stored Proc B From Stored Proc A

Jan 20, 2004

Hi all

I have about 5 stored procedures that, among other things, execute exactly the same SELECT statement

Instead of copying the SELECT statement 5 times, I'd like each stored proc to call a single stored proc that executes the SELECT statement and returns the resultset to the calling stored proc

The SELECT statement in question retrieves a single row from a table containing 10 columns.

Is there a way for a stored proc to call another stored proc and gain access to the resultset of the called stored proc?

I know about stored proc return values and about output parameters, but I think I am looking for something different.

Thanks

View 14 Replies View Related

Calling T SQL Stored Proc From CLR Stored Proc

Aug 30, 2007

I would like to know if the following is possible/permissible:

myCLRstoredproc (or some C# stored proc)
{
//call some T SQL stored procedure spSQL and get the result set here to work with

INSERT INTO #tmpCLR EXECUTE spSQL
}

spSQL
(

INSERT INTO #tmpABC EXECUTE spSQL2
)


spSQL2
(
// some other t-sql stored proc
)


Can we do that? I know that doing this in SQL server would throw (nested EXECUTE not allowed). I dont want to go re-writing the spSQL in C# again, I just want to get whatever spSQL returns and then work with the result set to do row-level computations, thereby avoiding to use cursors in spSQL.

View 2 Replies View Related

Proc Problem

Nov 20, 2006

Hi
I have this stored_proc - which works fine
ALTER PROCEDURE proc_Prod_AdvancedSearch  @Title VARCHAR(50) = Null,  @Category VARCHAR(8) = null,  @ReleaseClass VARCHAR(50) = null,  @BuyPrice DECIMAL(8,2) = nullASSET NOCOUNT ONSELECT *FROM ProductWHERE Title = ISNULL(@title, title)AND  Category = ISNULL(@Category, Category)AND  ReleaseClass = ISNULL(@ReleaseClass, ReleaseClass)AND  BuyPrice < ISNULL(@BuyPrice, BuyPrice)Return
except, when i type in something for the @title parameter, unless i type the exact match as title, it returns nothing
i would like it to return results if part of @title is similar to title
ive tried WHERE Title = ISNULL(' %' + @title + '%' , title) but it does the same thing as above
any ideas
cheers
 

View 4 Replies View Related

SQL Store Proc - Need Help

May 4, 2007

I need some help writing my request, I tried both of the following but it does'st seem to work.  Your sugestion would be appreciated.SELECT count(LeadId) FROM dbo.Cl_Leads Where AccntMng=@AccntMng and (Status = 'Won' or Status = 'Lost') and InsertDate BETWEEN @dtStart AND @dtEnd
 I also tried
SELECT count(LeadId) FROM (SELECT * FROM dbo.Cl_Leads WHERE InsertDate BETWEEN @dtStart AND @dtEnd)Where AccntMng=@AccntMng and (Status = 'Won' or Status = 'Lost')  This return and error: Incorrect syntax near the keyword 'Where'.
 

View 6 Replies View Related

Sql And Stored Proc

Jul 19, 2007

Im trying to perform an update with a stored procedure thats all working but
 an exception is thrown ....violation of primary key contraint....cannot insert duplicate pri key
I understand whats going on but how do you update some ones details if its protected this way.
?

View 3 Replies View Related

Help With SQL Stored Proc

Feb 22, 2008

I have a stored procedure , where i want to return identity column after insert but before insert i want to check if the record exist then select its identity value to return , after select statement it is retutrning null  CREATE PROCEDURE SP_Attendance1 (@DIVISIONID int,@EMPLOYEEID int,@CALLDATE datetime,@RECEIVEDDATE datetime,@DOC datetime,@SYSTEMNAME VARCHAR(20),@DELETED int,@attendanceID int output) AS---DECLARE @ID intIF EXISTS (SELECT ID  FROM TBLATTENDANCE WHERE EMPLOYEEID = @EMPLOYEEID AND YEAR ( CALLDATE ) = YEAR ( @CALLDATE)AND MONTH (CALLDATE) = MONTH ( @CALLDATE) AND DAY (CALLDATE) = DAY ( @CALLDATE)  )BEGIN SET  @attendanceID = SCOPE_IDENTITY()END ELSE BEGIN INSERT INTO TBLATTENDANCE  (DIVISIONID ,EMPLOYEEID ,CALLDATE , RECEIVEDDATE ,DOC,SYSTEMNAME ,DELETED )VALUES  (@DIVISIONID ,@EMPLOYEEID ,@CALLDATE , @RECEIVEDDATE ,@DOC,@SYSTEMNAME ,@DELETED ) ;SELECT DIVISIONID, EMPLOYEEID, CALLDATE, RECEIVEDDATE, DOC, SYSTEMNAME, DELETED,ID  FROM TBLATTENDANCE WHERE (ID = SCOPE_IDENTITY())SELECT  @attendanceID = SCOPE_IDENTITY()ENDGO  Kindly help with this  

View 5 Replies View Related

SQL Stored Proc

Jan 15, 2004

Hi,

I am trying to create a stored proc, that delivers a recordset, per the user requirements BUT,

I want to create a Geneirc search Proc that can handle a few criteria

I was wondering if it is possible to create a VB like Select case
depending on Information supplied to the stored proc

i.e
@Loc_Thing
@Loc_OtherThing

SELECT FirstName,LastName,CIty,Job,,Company,Webpage FROM RECORDSET WHERE
Select case @Loc_Thing
Case "Mickey"
LastName = @Loc_OtherThing
Case "Walt"
Company = @Loc_OtherThing

...... etc

is it possible to create a strored proc like this?
I have found a Select case in SQL, but it doesn't work I would like it?
Any Idea's?

View 1 Replies View Related

Strore Proc With Like %

Oct 1, 2004

This must be a simple one but look all over to find infos on the uses of like % in a store proc and I did'nt find anything. I know it's something wrong with my "%" and where to put the apostrophes.

Please could you check the following code and let me know what wrong with it.
Thanks

ALTER PROCEDURE dbo.GetSearchMultiColumn
(
@strColumnNamenvarchar (50),
@strSearchTermnvarchar (200)
)

as
if (@strColumnName = 'Camera')
begin
SELECT SystemId,CompanyName,City,State,Country,Camera1,Camera2,Camera3,Camera4 FROM Customers
WHERE Camera1 LIKE '% @strSearchTerm %' or Camera2 LIKE '% @strSearchTerm %' or Camera3 LIKE '% @strSearchTerm %' or Camera4 LIKE '% @strSearchTerm %'
return 0
end

if (@strColumnName = 'ZMotor')
begin
SELECT SystemId,CompanyName,City,State,Country,ZMotor1,ZMotor2,ZMotor3 FROM Customers
WHERE ZMotor1 LIKE '% @strSearchTerm %' or ZMotor2 LIKE '% @strSearchTerm %' or ZMotor3 LIKE '% @strSearchTerm %'
return 0
end

if (@strColumnName = 'Stage')
begin
SELECT SystemId,CompanyName,City,State,Country,Stage1,Stage2,Stage3 FROM Customers
WHERE Stage1 LIKE '% @strSearchTerm %' or Stage2 LIKE '% @strSearchTerm %' or Stage3 LIKE '% @strSearchTerm %'
return 0
end

View 1 Replies View Related







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