Quantcast
Channel: SQL Server Database Engine forum
Viewing all 15930 articles
Browse latest View live

Getiing Suspended status with High CPU utilization in exec dbo.sp_replmonitorrefreshjob Event Info

$
0
0

Hi,

We are facing one issue in our MS SQL Server 2008 Data Base related to high CPU utilization as well as high Disk IO (pls. refer to attached screens).

CPU and Disk IO utilization remains high when there is not replication is happening and it's directly impact to our Data Base performance. Kindly request to all please guide us on above issues to resolve it ASAP.

Thanks in advance.

Regards,

Amit


Amit


How do i get the server name of sql server 2008?

$
0
0
How do i get the server name of sql server 2008?, i have tried localhost and it didn't work

micah D

Help for Resource Governer

$
0
0

Hi, can anyone share what is the pros and cons for using Resource Governer

Is there a way to create a plan guide for this query?

$
0
0

How can i create a plan guide for this query,suppose i can't change the query text:

USE AdventureWorks2008R2;
GO
SET NOCOUNT ON;
GO

-- query plan statement starts

DECLARE @Group nvarchar(50), @Sales money;
SET @Group = N'North America';
SET @Sales = 2000000;
SET NOCOUNT OFF;
SELECT FirstName, LastName, SalesYTD
FROM Sales.vSalesPerson
WHERE TerritoryGroup = @Group and SalesYTD >= @Sales;

-- query plan statement ends

AdventureWorks2008R2's parameterization option is simple, i want this type of query can reuse plan:

DECLARE @Group nvarchar(50), @Sales money;
SET @Group = N'Other Country';
SET @Sales = 88;
SET NOCOUNT OFF;
SELECT FirstName, LastName, SalesYTD
FROM Sales.vSalesPerson
WHERE TerritoryGroup = @Group and SalesYTD >= @Sales;

I tried many times ,but it didn't work:

declare @xml nvarchar(max)-- the plan i want to reuse
set @xml = (select cast (query_plan as nvarchar(max)) 
from sys.dm_exec_query_plan (0x060006001464570B405D92620200000001000000000000000000000000000000000000000000000000000000))
-- create plan guide 
exec sp_create_plan_guide 
@name ='Test'
,@stmt=N'SELECT FirstName, LastName, SalesYTD
FROM Sales.vSalesPerson
WHERE TerritoryGroup = @Group and SalesYTD >= @Sales;'
,@type =N'sql'
,@params =N'@Group nvarchar(50), @Sales money'
,@hints = @xml;

Thanks.



Distributed transactions not working

$
0
0

Hi.

Please read this post carefully as I believe this is going to be a complex issue to resolve and I trust we've eliminated all commonly known causes while troubleshooting. We've had two DBAs and two infrastructure analysts working on this problem for more than a week with no progress.

I've been having trouble running distributed transactions between a clustered (WSFC 2012) and a standalone instance of SQL Server 2012 Enterprise.

Both MSDTC services are running and with all those parameters enabled in component services (allow inbound/outbound connections, network access, no authentication required, etc etc etc). Both servers are able to resolve DNS and reverse DNS of each other, even though they are in different domains. Distributed transactions are able to run fine between instances belonging to the cluster.

In both the standalone and the clustered instances, the following error is returned when attempting to run a distributed transaction:

OLE DB provider "SQLNCLI11" for linked server <LINKED SERVER NAME> returned message "No transaction is active.".
The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server <LINKED SERVER NAME> was unable to begin a distributed transaction.

When running a distributed transaction started from the clustered instance, the following error is generated in the sql server error log in the REMOTE, standalone instance:

"Recovery of any in-doubt distributed transactions involving Microsoft Distributed Transaction Coordinator (MS DTC) has completed. This is an informational message only. No user action is required."

This is NOT observed the other way around.

DTC Ping was returning the following message for either instances:

There are no more endpoints from the endpoint mapper

Acording to the link below, this sugests either a firewall problem OR the operating system running out of DCOM ports.

http://blogs.msdn.com/b/distributedservices/archive/2008/11/12/troubleshooting-msdtc-issues-with-the-dtcping-tool.aspx#Therearenomoreendpoints

However, we have already ruled out these options as there are no firewalls between these hosts and the server in which both SQL Server instances are running are dedicated to them, so there are no other running services which could cause port overlapping that i know of. Listing open sockets in command prompt confirms this. We have also tried to increase the port range for MSDTC manually, but that didn't change anything. The ONLY open socket, in both servers, that is documented for MSDTC is port 135, which is used for RPC so i believe its alright. There are no other open sockets for ports 1434 or 5100-5200.

After we installed a few aditional .net components on both servers, DTCPing test started to run successfully from the clustered instance to standalone, and clicking "run" in standalone did nothing. The error messages in SQL Server remained as they were.

One interesting remark, although I'm unsure wether this has anything to do with the problem, is that the physical machines in which the cluster nodes run have two MSDTC services, one local and one clustered. I've never seen this setup before. Strangely, the local, disabled MSDTC service displays a uniqueidentifier in services.msc that is listed as a clustered resource in regedit

This service wont start and will generate the following errors in event viewer:

MS DTC log file not found. After ensuring that all Resource Managers coordinated by MS DTC have no indoubt transactions, please run msdtc -resetlog to create the log file.

MS DTC Transaction Manager start failed. LogInit returned error 0x3. This is expected if the corresponding volume has been restored (search for kb article regarding the issue). In all other cases, contact product support.

OBS.: The clustered MSDTC service is running fine and DT works between two different active clustered instances, either on the same node or on distinct ones.

When running a distributed transaction from one of the clustered instances to the standalone instance, the transaction is listed as "active" for long period of time in the clustered server before timing out in SQL Server and aborting. It is NOT, at any time, listed as an in-doubt transaction.

Changing the server parameter "in-doubt xact resolution" to 1 in both instances didn't have any effect either.

Questions:

1. Could this problem be related to the presence of multiple MSDTC services in the clustered instance?
2. Why won't the MSDTC local service start in the clustered service?
3. Why is the in-doubt transaction message generated for the standalone instance, but not for the clustered one?
4. Does MSDTC even work between a clustered and a standalone SQL Server instance???
5. In the clustered instance, SQL Server resource is not dependant on MSDTC. Could this be interfering with transactions outside the clustered instances?

Unable to Send mail using Database Mail feature SQL Server 2008 R2

$
0
0

Hello,

Fellow DBA's...I have been trying to configure Database Mail on SQL Server 2008 R2 but I am betting below error.
I am able to send Mail by connecting to my Mail server using Telnet but no luck.

----------------------------------------------------------------------------------------

Date1/6/2013 4:03:20 PM
LogDatabase Mail (Database Mail Log)

Log ID154
Process ID7756
Mail Item ID45
Last Modified1/6/2013 4:03:20 PM
Last Modified Bysa

Message
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 14 (2013-01-06T16:03:20). Exception Message: Cannot send mails to mail server. (Command parameter not implemented. The server response was: 5.5.2 <Server Name>: Helo command rejected: need fully-qualified hostname).
)

----------------------------------------------------------------------------------------

I have tried every possible thing. referred to different forums and Changed the setting of  SMTP Virtual Server in IIS  but still no luck

I would appreciate if anyone out there has solution to this issue.

Thanks!
RB

Persistancy of user account & its permission in TempDB

$
0
0

Hi,

I have observed an interesting issue in sql server 2012 (my version is 11.0.5532)

1. Create a sql server login, let's call it [Test]

2.Create a user (let's call it TestUser) in TEMPDB with the following script

USE [tempdb]
GO
CREATE USER [TestUser] FOR LOGIN [Test] WITH DEFAULT_SCHEMA=[dbo]
ALTER ROLE [db_datareader] ADD MEMBER [TestUser]
ALTER ROLE [db_datawriter] ADD MEMBER [TestUser]
GO

Now reboot the server, and since TempDB will be recreated during sql service restarts, I expect the newly created TestUser in tempdb to be disappeared. But it does not, it is still there.

Now, let's create another user, this user will matching an existing Windows Login account in the sql server, 

USE [tempdb]
GO
CREATE USER [TestUser2] FOR LOGIN [MyDomain\XXX] WITH DEFAULT_SCHEMA=[dbo]
ALTER ROLE [db_datareader] ADD MEMBER [TestUser2]
ALTER ROLE [db_datawriter] ADD MEMBER [TestUser2]
GO

and reboot the server again, this time, in TempDB, TestUser2 disappears (as expected) while the original TestUser still persists.

In summary, in TempDB, if I create a user with a regualr sql login and also create another user with a windows login, after sql server restarts, the user with the sql login will still exist in tempdb while the one with the windows login will disappear.

Does anyone know why this is the case?

Thanks,

Jeff_yao

Disable Shared memory & Named Pipes protocols - Post implementation issues

$
0
0

Hi,

 As per security guidelines, we disabled Shared memory & Named Pipes protocols and enabled "TCP/IP" only. Also, we changed the port# from 1433 to 1533 and after that, in management studio, SQL Server Error logs is not openning up and SQL Agent Service doesn't start.

 Error while opening SQL Server Error Logs in SSMS:

The description for Event ID 17052 from source MSSQLSERVER cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

Severity: 16 Error:10061, OS: 10061 [Microsoft][SQL Server Native Client 11.0]TCP Provider: No connection could be made because the target machine actively refused it. 

the message resource is present but the message is not found in the string/message table

Error while trying to start SQL Agent Service from the configuration manager:

SQLServerAgent could not be started (reason: Unable to connect to server '(local)'; SQLServerAgent cannot start).

 We changed the Server host in the registry by entering <ServerName>,<Port#>. This resolved SQL Agent Service startup issue. After startup, we tried to run jobs but they all are failing with the below error.

Job runtime Error:
Could not load package "Maintenance Plans\Daily DB Backups" because of error 0xC0014062.  Description: The LoadFromSQLServer method has encountered OLE DB error code 0x80004005 (Login timeout expired).  The SQL statement that was issued has failed.  Source:   Started:  4:40:45 PM  Finished: 4:41:00 PM  Elapsed:  15.547 seconds.  The package could not be loaded.  The step failed.

 Resolution: If I create an alias name then all problems are solved.

 Question: Alias name is the only one solution or is there any other turn around? For some reason, I’m not at all comfortable with alias name. I feel like cheating. :-) .

 PLEASE COMMENT


If you feel that I have answered your question then please "Mark as Answer".


Why Error 5118? My disk is not compressed?

$
0
0
Hi all,

I encountered problems like the one ever posted here and in the forum SQL Server Tools.
In one case, the user solved the problem by turning dynamic disk into static (basic) disks.
In another case, the soution was not known.

Here is the message I encountered.

Msg 5118, Level 16, State 1, Line 1

The file "E:\Database\Microsoft\Usage.mdf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.

The problem is : my disk is static (basic), and not compressed. How can this happen?
I also have Oracle installed. Oracle instance is able to process files in the disk E.
Again, the disk E is not compressed since the beginning of its creation, neither is disk D.
If I moved the data files and transaction log files to disk D, I'm able to attach the database.
How can this be?

Thank you,

Bernaridho

varchar to numeric

$
0
0

Hi All..
I am writing a query to select and the stop at the middle,  and say

Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.

How can I find the problem row quickly ?

SQL Server Job Help

$
0
0

Hi All,

I have a maintenance  job In PROD server which execute on every Sunday and it will take almost 7 to 8 hours or sometime more than it  (depending upon index fragmentation) to complete
I have to execute maintenance job in Reporting server after completing the prod server maintenance job

Till now I am manually executing maintenance job in Reporting server, when I got job completion mail from PROD server - I want to do it Automated please suggest.


How SQL Server Utilizes Memory (RAM) while Index Rebuild.

$
0
0

Hello,

I had a conversation with one of the SQL Server DBA today regarding Memory/Cache utilization while SQL is re-building indexes. Could someone please help me to understand how SQL Server uses memory while rebuilding index on tables of a database. 

1) How SQL Server uses memory while rebuilding indexes ?

2) Will re-indexing will SQL server save/cache all the data pages associated to that table in memory ? If so what are the chances this will get flushed from memory?

3) Also, How long a data page will stay in memory if there are no reads/writes on it ?

3) Appreciate if you can post any articles or analysis related to this.

Thank you for your help.



Database Mail error

$
0
0

Hello

I am new to SQL Server 2008. I am upgrading from 2000 to 2008 and currently working on Database Mail.

I can send a test mail to say an email address like abc@xyz.com

If i create an operator with the above email address, I am getting this error (in Database Mail log) when i send a test mail to Operator. 

Message
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 3 (2010-09-07T10:31:24). Exception Message: Cannot send mails to mail server. (A recipient must be specified.).
)

Any idea why Database Mail is able to send email when email address is specified and fails to send email to the same address when used in operator?

Thank You,

V

Restoring from a network drive

$
0
0

Using SQL Server 2008R2, I am trying to restore a .bak-file from a network folder (on a NAS)

I keep getting the following error:

Msg 3634, Level 16, State 1, Line 2

The operating system returned the error '1317(failed to retrieve text for this error. Reason: 15105)' while attempting 'CreateFileW' on '\\<IP HIDDEN>\rppt\backup\myDB.ndf'.

Msg 3013, Level 16, State 1, Line 2

RESTORE DATABASE is terminating abnormally.

According to my Google searches, error Message 1317 means 'There is no such user'

I have set the SQL Server service account to a domain user. The user has also full privileges to the network folder I am trying to access

SQLCMD Mode vs SQLCMD command line Utility

$
0
0

I noticed some strange behavior with column ordering on a view.  When I run the below script using SQLCMD Mode in SSMS, the columns show in the correct order.  If I run the same command using the SQLCMD command line utility, the view's columns get put in ABC order.

CREATE VIEW [dbo].[SomeView] WITH SCHEMABINDING AS

SELECT ACol, QCol, BCol, DCol FROM dbo.SomeTable

I saw in MSDN that the command line utility runs the SQL using ODBC vs the SQLCMD mode uses SQLClient framework but I'm not able to find any information on the differences.  Anyone else experience this behavior?




Duplicate Key error from mutually exclusing Select/Union - How can this be?

$
0
0

Hello, I have a web production system that has had this problem twice now. This logic is run hundreds of times a day for each user as it is part of the application dashboard and this has only occurred twice since May.

I am creating a temporary table that is loaded with the result set of a Select/Union that fails when I try to create a unique key on it. As far as I can tell, the rows should be mutually exclusive and the selected key: EVENT_ID is a unique identity primary key column and all of the referenced columns in the SQL below are defined as NOT NULL. 

My only explanation is that an update was applied between the 2 union sides that caused the same row to be selected on both sides. I checked the key entries referenced in the duplicate key errors and on both occasions the row had been updated at virtually the same time as the duplicate key error.

Here is the SQL:

drop table tmp_Martinator_empqueueevents 
;
create table dbo.tmp_Martinator_empqueueevents ( EVENT_ID integer) 
;
insert into tmp_Martinator_empqueueevents 

SELECT EVENT.EVENT_ID 
FROM EVENT with (nolock) 
WHERE EVENT.DATA_IMPORT_LOG_ID >= 0 
AND EVENT.STATUS_CODE_ID in (283, 284) 
AND EVENT.ASSIGNED_EMP_ID = 97 
union 
SELECT EVENT.EVENT_ID 
FROM EVENT with (nolock) 
WHERE EVENT.DATA_IMPORT_LOG_ID >= 0 
AND EVENT.EVENT_TYPE_ID = 293 
AND EVENT.STATUS_CODE_ID = 285 
AND EVENT.REVIEWED_FLAG = 0 
AND EVENT.ASSIGNED_EMP_ID = 97 
;
create unique index event_extract_pk 
on tmp_Martinator_empqueueevents ( EVENT_ID ) 
;

I don't see how the same row could end up on both sides of this union and I am running Read Committed so that updates should not interfere with this either.

Any ideas or tips would be greatly appreciated, thank you.

Join hint ignored - very bad query plan results

$
0
0

I'm trying to get a query that's being generated by SSAS to perform acceptably. Because this query is (at least partially) generated by SSAS, I don't have complete control over the query text.

The problem - The query looks roughly like this:

select -- a bunch of columns from T1 -- table with ~40,000,000 rows inner loop join T2 on T2.t2id = T1.t2id -- table with ~16,000 rows inner loop join T3 on T3.t3id = T1.t3id -- table with ~200,000 rows

inner loop join T4 on T4.t4id = T1.t4id -- table with ~200,000 rows left loop join T5 on T5.t3id = T1.t3id and T5.t6id = T4.t6id -- table with 0 rows where -- some uninteresting conditions

T1 is a Fact (or Measure) table, T2, T3 and T4 are Dimension tables, T5 and T6 are involved in the filtering of the query.  Every row of T1 WILL match exactly one row in each of T1, T2 and T3.

You'll note that I've hinted all of the joins - according to the documentation, using join hints forces join order (which is consistent with the plan that's produced).  There's no mention that join hints can be transparently ignored by the optimizer, but that seems to be precisely what's happening.

In the plan that results, the join to T4 is done as a hash join, with T1*T2*T3 (40,000,000 rows) on the "top", so it ends up trying to build a hash table with 40,000,000 rows, resulting in very high tempdb activity and very poor performance (I don't know how poor - I've never let it finish).

I can see part of the reason why it's making this join choice - the estimate of T1*T2*T3 is only 35,000 rows, even though T1 has 40,000,000 rows and the join will hit on every row.

Questions:

1. What can I do to the query or the database to improve the estimate on the join to T3?

2. What can I do to the query to force the optimizer to use a loop join like I asked? 

Version is SQL Server 2008 R2 SP2 Developer Edition X64.

OS is Windows 2008 R2

Machine is dual-quad-hyper-threaded CPU with 96Gb of RAM and several Tb of disk spread over 8 spindles and SSDs.

I've seen this query perform well before - I've been tuning this query for going on 7 years now and I've never seen it perform this badly that I can recall.  Not sure if it's something that's changed in SP2, or something about the distribution of data in this particular database that's changed, but something's sure changed.


-cd Mark the best replies as answers!





Unexplained sql join statement error

$
0
0

I have 3 tables having this unique id one of them has a different type of data type.

The following is the data type in the 4 tables representing the same column :

users : userid(varchar(20))
finewaiver : Requester(int)
loanstudents : student(int) 

This statement works without the where criteria, but when I tried adding the search criteria there was some error. Although this is not the correct as it is a long way to produce the same result below and it might affect performance by joining too many redundant tables. I just want to know the logic of why it did failed. Loanstudents was never needed in the first place as the finewaiver already holds the necessary info for loans and the requester table. Its either I change the whole statement to the one in the workaround or I needed to cast the @userid to a varchar(20) type.

Select * from fineswaiver fw 
join loans l on l.ID = fw.LoanID 
join LoanStudents ls on ls.LoanID = l.ID 
join Users u on u.ID = ls.student
where  u.userid =@userid 

This was my workaround and it works :

Select * from fineswaiver fw 
join Users u on u.ID = fw.Requester
join loans l on l.ID = fw.LoanID 
join LoanStudents ls on ls.LoanID = l.ID 
Where  u.userid =@userid 



memory utilization

$
0
0

Hi All,

There was stackdump which occurred on 29th July, and I want to find out memory utilization at that time on that instance, and I do not have complete dump in the log, I only have as BEGIN STACK DUMP and Non-yeilding scheduler in the error logs.

Now how to find out memory utilization on 29th July at 12:52 am?

Thanks.

Unable to drop filegroup; The filegroup cannot be removed because it is not empty

$
0
0

SQL 2008R2SP2 Standard Edition 64-Bit on Windows 2008R2 Enterprise.

I have an empty file group (no files assigned) that is not the default file group. I have never setup or tried to set up "Partitioning" (it is Standard Edition).

When I try to "Remove" the FG via SSMS GUI or T-SQL I get the error message.

Based on another (very old post) I checked sys.Indexes and found two indexes for one table still assigned to the file group.  (The table has 0 rows.)  Select * from the table did not generate an error!! and returned an empty result set as expected.

I Dropped the two indexes (one is PK the other is a Unique Constraint) and recreated them on different file groups.  This was successful and sys.Indexes shows the changes.

Now I can drop the File Group.

Why would the system let me

  1. Shrink (empty) a file that contained indexes for a table?
  2. Drop  a File that contained indexes for a table?
  3. Access a table in a file that does not exist?
  4. Drop Indexes from a file that does not exist

Seem like I should have gotten an error message somewhere around Step 1. :)

Thanks,


Ray

Viewing all 15930 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>