SQL Server 2008 :: List Of Commands That Require Exclusive Access In Order For Command To Complete

Aug 10, 2015

Any list of commands that require exclusive access in order for the command to complete? I had an instance today where a DBA executed sp_changedbowner command which is the alter database command on a production database and it locked it up.

View 0 Replies


ADVERTISEMENT

SQL Server 2008 :: Does Change Data Capture Require A Table Have Primary Key

Jan 13, 2013

Or can it record before and after column changes based on the LSN only?

An extract from a file based legacy accounting system is performed every night. The system does not have a primary key because transactions are managed through program code. (the more things change...). The extract is copied to text in Unix and FTP'd to Windows, where the file is loaded into SQL Server by kill & fill. Because of the expense of modifying the source system, there is enormous inertia/resistance to injecting a primary key at the source, so kill & fill it stays.

In reading about Change Data Capture, it seemed to me that column level insert update and delete are stored in tables that remember the before and after content of each column tracked. In my reading I have seen many references to the LSN to decide when and what to record as changed, but I have not seen any refereference to the necessity of a primary key for Change Data Capture to work. This is in contrast to replication, where the requirement for the existence of a primary key is made plain.

Is it possible to use Change Data Capture against a table without a primary key? How to use it to change the extract from kill and fill to incremental.

View 9 Replies View Related

Cant Restore SQL Server Databases: Exclusive Access Could Not Be Obtained

Jul 7, 2007



Hi everyone,



Hope somebody can help me on this.



I did a full BACKUP for two SQL databases using SQL Server Managament Studio. When trying to RESTORE the DBs, I get the following error:



"System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use. (Microsoft.SqlServer.Smo)"



There are NO users using the application. These are DBs for the Portfolio Server 2007 application.



After exploring a little bit, I found that there are several "SLEEPING" processes with an "AWATING COMMAND" flag. The processes come from the Portfolio Server Application, maybe from previous sessions.



Can they be deleted? if so, would there be any serious consequences?



Thank you for your help on this.



Oscar E.

View 4 Replies View Related

Can't Get The Complete List Of Tables Owned By The Dbo

Oct 10, 2005

Hi,

View 12 Replies View Related

Complete List Of Error Codes

May 12, 2006

Does anyone know where to obtain a complete list of error codes which can occur in SQL Server ? For example : errror number 547 is a foreign key violation - where can I get a complete list of these numbers and there descritions ?

I can't find it in BOL or anywhere

View 1 Replies View Related

How To Obtain Exclusive Access Via SQL

Feb 5, 2003

Hi,

i need to run a restore of a database overnight onto a different server using the live data .bak file. however the job failed on the first run (last night) with the error:

"Exclusive access could not be obtained because the database is in use. ...."

how do i gain this Exclusive use via an SQL statement please?

View 8 Replies View Related

Exclusive Access To DataBase

Jul 12, 2004

Hi.

I need to access a database to modify, updates,... massively . It's possible to lock a database and have exclusive access?

(SQLServer 2000)

thanks.

Francisco

View 2 Replies View Related

Trying To Get Exclusive Access To A DB For Restore.

Feb 11, 2004

I have created a SQL Agent job that is supposed to essentially duplicate a production database to another database. The code I am using is:

step1
__________________________________________________ ______
declare @sql varchar(8000)
set @sql=''
select @sql=@sql+'kill '+cast(spid as varchar)+char(13)+char(10)
from sysprocesses where dbid=12

--Print (@SQL)
exec(@sql)

step2
__________________________________________________ ________

RESTORE DATABASE HIWDYNARPT FROM PRDBACKUP
WITH REPLACE
__________________________________________________ ______

This works when I test it during the day, however when it runs at night I get the following error in the job log:

Database in use. The system administrator must have exclusive use of the database to run the restore operation. [SQLSTATE 42000] (Error 3101) Backup or restore operation terminating abnormally. [SQLSTATE 42000] (Error 3013). The step failed.

I'm not sure why this happens because I have killed all open threads in step 1, and then create my own new thread in step two. Maybe someone else is initiating a new thread to quickly between the steps???

Anyway, I am trying to use:
__________________________________________________ __
ALTER DATABASE HIWDYNARPT
RESTRICTED_USER
WITH ROLLBACK IMMEDIATE
__________________________________________________ ____

...as an alternative to the T-SQL killing PID's, but SQL 7.0 SP4 does not seem to support restricted user like 2000. It keeps giving me a syntax error. Does anyone have any suggestions?

If I bring step 1 and step 2 together, separated by "GO", could this fix the problem?

Thanks in advance!

Ryan Hunt

View 5 Replies View Related

Exclusive Access Could Not Be Obtained Because The

Dec 8, 2007

Could anybody give a lead as to what I can do get rid off this error please.

I alread tried following:
use master
go
Alter Database dbname set single_user with rollback immediate;
go

Still have the issue. SQL 2005 Server actually did lock the db.
So ran
Alter Database dbname set multi_user;
go
and refresh Query and it switch back to multi user.
But I can't restore db yet.

Thank you

View 1 Replies View Related

Multiple Tables To Create A More Complete List

Jun 26, 2014

My SQL knowledge is limited to only trial-and-error and on-the-fly learning, sadly. However, I've had past experience with VB and some earlier, more basic programming, so I don't find it that difficult to grasp; it's just rather overwhelming without any formalized training.

I'm trying now to solve a problem that involves a sales history report. Our sales history table lists only records for product lines which a customer has purchased in the past. However, the budgeting team needs a list of each customer with all product lines, even if they've never purchased, and they'd like to include an industry code value that is from another table.

So the way the tables are looking is this:

Sales_History as the main table with the appropriate data in it
Product_Lines as a reference to fill out the main table with non-purchased lines

Accounts as another reference that gives the industry code per the customer ID in the main table''I'm seemingly on the right track with the following, which tries to create a list of all product lines and the records from sales_history which match them:

SELECT sales_history.sah_sort_id,sales_history.sah_sortkey3,sales_history.sah_sortkey2_desc,
prod_lines.pl_prodline_id,prod_lines.pl_short_desc
FROM dbo.sales_history
INNER JOIN prod_lines ON sales_history.sah_sortkey3=prod_lines.pl_prodline_id

[code]...

However, this produces a list of only 21 rows, when there should be 41.

View 15 Replies View Related

Execute Sql Commands Through Command Prompt

Nov 15, 2007

Hi,

I wanted to know if there is a way to execute sql commands on the operating system's command line. If it is possible, then how do we do it ? For example to execute a SELECT * from Table statement what are we supposed to do ?

Thanks
S

View 2 Replies View Related

BACKUP Failed To Complete The Command Sp_prepexec;1

Feb 28, 2007

One of my SQL Servers (SQL 2000 SP4) is reporting this error in the Maintenance Plan. But shortly after it shows this error is does successfully backup my Databases (per log history), however the plan is indicating "failure".

I have no idea how to resolve this nor why it is happening.

Rob.

View 1 Replies View Related

Exclusive Access Could Not Be Obtained Because The Database Is In Use.

May 25, 2004

How to close the existing connections to a particluar database in sql server. Please note that i donot want to start stop sql server. I just want to close the existing connections so that i can do a restore on that database programatically.

I am using sqldmo for this purpose. Does anyone knows how to do that with sqldmo or is there any other method??

Waiting for your earliest replies

View 1 Replies View Related

Exclusive Access Could Not Be Obtained Because The Database Is In Use

May 31, 2008

Hi!

We're using a backup with sql server agent when doing a backup / restore
procedure. In some cases I get the following error when the restore job
fails:

Executed as user: DOMAINAdministrator. Exclusive access could not be
obtained because the database is in use. [SQLSTATE 42000] (Error 3101)
RESTORE DATABASE is terminating abnormally. [SQLSTATE 42000] (Error 3013).
The step failed.

Is it related to unhandled lock? I've resolved this by restarting the sql
server. But is there a way to avoid such issues?
One more question. Is it OK to backup/restore database while there're users
connected? Or I can do only backup?

View 2 Replies View Related

How To: Implement Exclusive Access To A Given Record.

May 5, 2008

Purpose
I would like to know if it is possible and if so how to implement exclusive access to a given record within in a database table.

Example
For example, you can open a file system file with exclusive access so other processes cannot access the file until it is released. I would like to implement a solution that provides this same exclusive access at the database record level. Preferably a solution that does not require creating and managing table access state flags. (i.e. €“ FieldName.State = (Closed, Opened, Exclusive)) I would like for the database server to mange this solution and return an error status when trying to access a record that has been opened exclusively. Furthermore, I would like to avoid using triggers.

Application Utilization
I€™m working on a system that has multiple threads that are each responsible managing data from the same normalized table. Each of these system threads work on the same unique record in parallel. Therefore it is possible that thread (0)€™s changes could be overwritten by thread (n)€™s. I would like to have each thread open the unique record exclusively and release it when finished. All of the other threads would loop until the record is released.

Questions

1. Is it possible to implement this at the server level?

2. What would be the easiest best practice for implementing this functional requirement?

Thanks,
Sean

View 5 Replies View Related

Exclusive User Access To Database

Sep 29, 2007

Hi All,

My question is regarding SQL Server database security. I want to create a login using SQL Server Authentication and assign it db_owner rights for my database. So far so good. But the critical part is that I want to give exclusive rights for my database to this user only i.e. no other users (dbo, guest etc) should be allowed to access my database.

It will be good to present here the scenario which I need to implement. I am running an ASP.NET application that uses SQL server 2005 db at back end. The database server might have other databases as well but I don't want the administrator (either SQL server admin or the server administrator) to be able to get access to my database or even view the schema. I don't want any other user except my own user to be able to detach the database or perform backup or restore operations.

I hope I was able to deliver the requirement.

View 6 Replies View Related

Exclusive Access Could Not Be Obtained Because The Database Is In Use

Apr 11, 2007

Hi



I am trying to use sql server 2005 management stodio to restore a database. But I got this error message:



Exclusive access could not be obtained because the database is in use



Anyone know how to solve this problem?



Thanks



Li

View 45 Replies View Related

Exclusive Access Could Not Be Obtained Because The Database Is In Use.

Jun 15, 2007

I have a test database that is automatically restored from the live database each day at 2:30AM. I recently started receiving this message:

Exclusive access could not be obtained because the database is in use.

and the restore is not able to occur.

Any ideas on how I can prevent this from happening?

View 1 Replies View Related

Msbuild And Sn Commands Are Not Recognized On Command Prompt. Please Advise.

Nov 14, 2005

I have downloaded and "run" these programs:

View 6 Replies View Related

Changing Field Property To Not Require From Require?

Nov 6, 1998

Hi everyone,

I have a table which have several fields. I have a field that is made required by mistake. I would like to change this field to not require. Can someone help with the syntax?

Any help is greatly appreciate.

View 1 Replies View Related

SQL Server 2008 :: Show Item Only Once In A List?

Jul 30, 2015

write a query that lists item, mfg serial number, and inspection date. The caveat is that, where there is more than one record for an item, he only wants item listed once. For example:

PartNumberInspectionDateManufacturerSerialNumber
1A144878/4/2013.1101VAS073-7
3L115931/28/2014009VAS206-1
1/29/2014009VAS206-1
2/21/2014009VAS206-1
7/22/2014009VAS206-1
2A285631/1/2015010115ND9CV02
1A203921/3/2015010315ND9PV45
1/4/2015010315ND9PV45
3/1/2015010315ND9PV45
2A2794310/20/20120103700P003

View 9 Replies View Related

SQL Server 2008 :: Command For Adding New Drives?

Aug 26, 2015

Currently we're running everything on C: but I've convinced management to split out, what's the command to add drives?

View 9 Replies View Related

SQL Server 2008 :: How To Find Order Of Lock Taken And Released

Feb 16, 2015

I have express edition [advance] of sqlserver 2008 r2 , is it possible to trace every event with out using profiler as u know it does not ship with it.

Basically i want to see how locks are taken and released in each isolation level when query is executed. I am using

SELECT resource_database_id, t.resource_type , t.resource_associated_entity_id,partitions.index_id,blocking_session_id,
indexes.name as index_name,o.name,
t.request_status, t.request_mode,t.request_session_id,
t.resource_description

[code]....

But i am not sure of the order becuase total_elapsed_time is same for many locks

like

resource_typeresource_associated_entity_idrequest_session_idrequest_modeindex_namenameresource_description
DATABASE051SNULLNULL
OBJECT209427886651Sch-SNULLwt
OBJECT209427886652IXNULLwt
PAGE7205759715088793652IXPK_wtNULL1:204815
KEY7205759715088793652XPK_wtNULL(4fb98fd9bfad)
DATABASE052SNULLNULL

View 5 Replies View Related

SQL Server 2008 :: Find Out Duplicate Order Sequence

Jun 30, 2015

In my asp.net project there are about 100 drop down list.I created a table to store data for drop down list in which including [DropdownID],[Order Sequence] and [Description] three columns. The sample like below. Data was input manually by a user. How to code to find out duplicate [OrderSequence]?

DropdownID--OrderSequence--Description
1-------------0--------------AAA
1-------------1--------------BBB
2-------------0--------------YYY
2-------------1--------------XXX
2-------------2--------------QQQ 'DUPLICATE OrderSequence
2-------------2--------------WWW 'DUPLICATE OrderSequence
2-------------3--------------RRR

View 2 Replies View Related

SQL Server 2008 :: List Store Procedures Contents?

Jul 27, 2015

who i can to list the content of all store procedures and funtions in text file ?

View 3 Replies View Related

SQL Server 2008 :: Executing Query / SPs Through Command Line

Sep 23, 2015

How do I execute below scripts using CMD:

Please Note: SQL server 2008r2, default instance with window Authentication.

1. Select * from Adventurewoks2008.Person.Person where Id = 5

2. Exec usp_getemployee (with parameter Manager_id = 100)

3. I have a folder named 'MyFolder' which contains 3 store procedures (usp_A, usp_B and usp_C).

How do I execute all 3 using CMD against AdventureWorks database.

View 9 Replies View Related

SQL Server 2008 Express Command Line Installation

Mar 25, 2008



Hi
I need to Install the SQL server 2008 express with Instance name and Sa password parameter in silent mode . I tried couple of command line arguments for this. but It didn't work, I got the setup failure error message
"The setting 'QB' specified is not recognized.Error code 0x84B40003."
Can any one help me with this?

These are the commands I tried.

1) sqlexpr.exe /qb instancename="MACHINENAMESQLEXPRESS2008" SCCCHECKLEVEL=IncompatibleComponents:1;MDAC25Version:0 ERRORREPORTING=1 SQLAUTOSTART=1 SAPWD="PWD" SECURITYMODE=SQL DISABLENETWORKPROTOCOLS=0"

2)SQLexpr.exe /qb /ACTION=Install /FEATURES=SQL /instancename="MACHINENAMESQLEXPRESS2008" SAPWD="PWD" SECURITYMODE=SQL


Thanks in advance.

Regards,
Nav.

View 1 Replies View Related

SQL Server 2012 :: List Of Order Numbers Based On Stock Availability - Filter Results?

Dec 23, 2014

Trying to build a list of order numbers based on stock availability.

The data looks something like this:

OrderNumber Stockcode quantityordered quantityinstock
123 code1 10 5
123 code2 5 10
124 code3 15 20
124 code4 10 10

In this case I would like to output a single result for each order, but based on stock availability order 123 is not a complete order and 124 is so the results will need to reflect this.

View 1 Replies View Related

SQL Server 2008 :: Converting Adjacency List To Hierarchy Table

Feb 10, 2015

I have been trying to convert an existing table that used adjacency list model (parentid,childid) to a table that use hierarchy Id type. So early on, I notice my original data does contains multiple roots. So I took a step to create dummy nodes to ensure all nodes fall into a single root structure. Another important fact is that each child node can have multiple parents.

My original source table contains 22461 records, when running the query below step 2 produces explosive number of records around 175,000+ records. I spent hours study the result and couldn't understand what actually causing this, I ran it against small set of test data I didn't seem the issue caused by child with multiple parents.

select * from SourceTable -- produces 22461 records

--step 1: first, get row number of child records in each parent

SELECT ChildID,ParentID, ROW_NUMBER() OVER (PARTITION BY PARENTID ORDER BY PARENTID) as Num
INTO #RelationshipTmp
FROM SourceTable;

[Code] ....

View 1 Replies View Related

SQL Server 2008 :: Filter List Of Employees Where Sum Of VALIDATED Hours Is Less Than 80?

Mar 12, 2015

How do I filter a list of Employees where the Sum of "VALIDATED" hours is less than 80? For example.

Here is the flat table

SELECT EMP_NO, hours, IsValidated, rate_type
FROM Pay_Records
WHERE pay_period_id = 2
Order by EMP_NO

Output will be something like this

12345 | 2 |true |REG
12345 | 15 |false |OVR
12345 | 30 |true |OVER
33334 |2| true |REG

Total Validated hours for the Employee 12345 will be 32 NOT 47. How do I list employees who worked less than 80 validated hours. The hours are validated only when it is true.

View 2 Replies View Related

SQL Server 2008 :: How To Change Query So Apple Does Not Show Up In List

Apr 2, 2015

I am trying to print Companies with less than 100 employees for all dates.Here's my table structure

Create table CompanyEmployeeArchive(
Company varchar(100) not null, Employees int, Dateinserted date)

Insert into CompanyEmployeeArchive values('Microsoft',1001,'2015-01-01')
Insert into CompanyEmployeeArchive values('Microsoft',1050,'2015-02-01')
Insert into CompanyEmployeeArchive values('Microsoft',1600,'2015-03-01')
Insert into CompanyEmployeeArchive values('IBM',10,'2015-01-01')
Insert into CompanyEmployeeArchive values('IBM',80,'2015-02-01')
Insert into CompanyEmployeeArchive values('Apple',90,'2015-01-01')
Insert into CompanyEmployeeArchive values('Apple',900,'2015-02-01')
Insert into CompanyEmployeeArchive values('Apple',1000,'2015-03-01')

I want companies that have employees less than 100 for all dates i.e. Only IBM. Apple has < 100 employees only on one month.Select Company, dateinserted, employees from CompanyEmployeeArchive group by company,dateinserted,employees having employees < 100 order by company, dateinserted this query lists Apple too. How can I change the query so Apple does not show up in the list.

View 4 Replies View Related

SQL Server 2008 :: Display List Of Indexes - Add Database Name In Results

Apr 6, 2015

I written a proc to display the list of Indexes But I needed to print the database where the objects do belong to. How I should write the Dynamic script to add the database Id? I thought to use derived table kind of stuff, but unable to find a solution.

ALTER PROC [dbo].[USP_INDEXCHECK]
AS
DECLARE @sql NVARCHAR(max)
DECLARE @DB VARCHAR(max)
DECLARE databasecursor CURSOR FOR

[Code] .....

View 2 Replies View Related

SQL Server 2008 :: XML Nodes To Retrieve Child And Its List Of Values

Apr 8, 2015

i was trying to use the XML read functionality using t-SQL for XML attached.The column is coming with the token names and token-values in XML format and we are using the XML nodes() functionality to read the token names and token value.I am able to read only the parent token names and its values(using the sql attached) and could not be able to get the child token names and its values.how can i acheive the tokenNames with its values with the SQL query.i am attaching both SQL script which i am using and the XML entity.

View 9 Replies View Related







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