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

Procedure for giving range of unique identity values produced duplicate ids after sql cluster failover

$
0
0
Hello,

we use the following (german) sql2008r2 environment
===================================================
Microsoft SQL Server Enterprise Edition (64-bit)
Microsoft Windows NT 6.1 (7601)
NT x64
10.50.2789.0
4-node failover cluster
===================================================

The following procedure is executed by serveral self programmed .net windows services installed on 4 application servers.

CREATE PROCEDURE [dbo].[prc_GetRsnVergabeByTyp]

    @Typ        VARCHAR(50)
    ,@Anzahl    INT

AS

BEGIN

    IF (@Anzahl < 1)
    BEGIN
        RAISERROR('Value must be greater than 0!', 16, 1);
    END;


    UPDATE
        dbo.RsnVergabe
    SET        
        WertVon = (WertBis + 1)
        ,WertBis = (WertBis + @Anzahl)
        ,GeaendertAm = GETDATE()
        ,GeaendertVon = SUSER_NAME()
    OUTPUT
        inserted.WertVon
        ,inserted.WertBis
    WHERE
        Typ = @Typ;

END

Today the sql-instance with this logic crashed and a cluster failover happened (as expected).
Directly after the instance was online again (on another sql server node) we received 1.000 "primary key" failures within the application.

Our dba found the following message in the windows eventlog:
------------------------------------------------------------
The Transaction (UOW=%1, Description='%3') was unable to be committed, and instead rolled back; this was due to an error message returned by CLFS while attempting to write a Prepare or Commit record for the Transaction.  The CLFS error returned was: %4.
------------------------------------------------------------

As a result of team research we think that the procedure was executed by a windows service which received a normal block of 1.000 ids successfully.
The server crashed before the update on dbo.RsnVergabe could be written to disk (ldf and/or mdf). After failover a windows service requested a new block of 1.000 unique ids.
Normaly those ids should have never been sent by the database before. But the sql server returned the same ids that have been returned in the previous request. This resulted in our primary key problem.

Might this be the reason for our problem and how can we prevent this situation in future.

Thanks for any advise.

Best regards
Thorsten Müller

SQL inconsistency failure (EventID 5243 and CHECKDB msg 8964)

$
0
0

Hello Community,

Monday there was a failing SCSI Controller at my hosting company, my hosting company hosts my SQL and SharePoint Server.
I saw this in my eventviewer (ID 5243) the Content database was failing, my hosting company did a live migration to another server.
The backup is from 2 weeks ago, so thats not really an option because there is a lot of content added to the database in the meantime.

I did a CHECKDB, I have listed all the errors: http://pastebin.com/ThJFrUU2

What is the best way to fix this problem without using a backup?

Greetings and thanks!,

Pascal


P.S: The database version is SQL 2005 Workgroup Edition SP2

Why DTA suggests to create statistics?

$
0
0

Hi,
Database Engine Tuning Advisor suggests to create Statistics(see below picture).  I am under an impression that statistics are updated automatically(autostatistics update = true for DB).

What does this mean? Should I really be creating seperate objects with script to create statistics?



SQL server Performance tuning training

$
0
0

Hi,

I am looking for best available online training on SQL server Performance tuning. Could you please suggest if you know any good training provider.

Loading Data From Excel sheet2007 To Sqlserver2008 using storedprocedure.

$
0
0

Hi Friends,

                   I am getting Error When I am Loading Data from Excel2007 Spread Sheet To Sqlserver2008 Using Ole db.Ace Provoder12.0.Actually I created Stored Procedure To Load the Data From Excel2007 TO Sqlserver.I Executed Store procedure Values Are Inserted At First Time After 10Days I am Trying To Execute That Stored procedure Procedure Is Not executed Its Giving Below Error And Also I Created Two Jobs To Load The Data I scheduled Like Every Month 1 Day.I Ran Manually after 10 Days I am getting Below Error.

          

                             OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message"'C:\data\abc.xlsx' is not a valid path.  Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.".
Msg 7303, Level 16, State 1, Line 2
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".

Please Can Anybody Resolve MY Problem Its Urgent.

SQL Error - On Sharepoint Server

$
0
0

Hello

I have Sharepoint databases on Sharepoint server. And I checked Event Viewer on the server. And I get following error message continuously.

"An exception occurred while enqueueing a message in the target queue. Error: 15517, State: 1. Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission."

I have no idea what is this error. And how i can solve this?

Please help

Thanks

user db file, mdf, or ldf, won't shrink

$
0
0

I have a sql 2008 user db that I can't shrink pass the initial db file size. So, I tried to change the initial file size of the db to smaller.  I am doing it via the SSMS GUI and it won' t save the smaller size.

How to shrink it without restarting the SQL service?  BTW, I cantn't back up ether, because the file size is too large; which is the reason I am trying to shrink it.


-- IBM has jobs for USA employee to work oversea (India) and get their wages.

Policy-Based Management: Compatability Level IN Version100, Version110

$
0
0

I am trying to create a condition to test the compatability level of a database to ensure that it is either Version100 or Version110 that will work on either a SQL2008R2SP2CU3 or SQL2012 server.

I have tried:

@CompatabilityLevel IN Array(Version100,Version110)

@CompatabilityLevel IN Array('Version100','Version110')

But I get the error "Requested value 'Array(Version100,Version110)' was not found

or

But I get the error "Requested value 'Array('Version100','Version110')' was not found


Buffer Cache Hit Ratio is 0 %, threshold value for this monitor is 92%

$
0
0

i usually get this message

Buffer Cache Hit Ratio is 0 %, threshold value for this monitor is 92%

I checked PLE> 6000

having memory > 18 GB

System memory 24 GB.

No Dropclean* commands executed. BCHR now 100%.

How can i trouble shoot this?

i checked there was update stats command was executing.

can this command brought BCHR to 0%? . i think this is possible

Please guide me


Manish


Page File configuration

$
0
0

I have SQL servers running 2005, 2008, and 2012. I do have about 64, 128 GB memory in some of them. I have also configured SQL to manage memory and given only 6 GB to the OS.

The question is how should the pagefile be configured? with which formula? I have been using 1.5 * the RAM in the past. if 1.5 * RAM is right, should it be 1.5 * 6 GB (memory allocated to OS) or 1.5 * total memory installed on the box?

and does VM matters?

I have already read this article http://support.microsoft.com/kb/2160852

Thanks!


Alert from TechNet Posting

strange behavior with in-line string concatenation

$
0
0

Hello!

We recently upgraded to SQL 2012 (64 bit).

We are noticing a difference in behavior as it relates to string concatenation.

Part 1 of the following script creates a test table populates with the data.

Part 2 of the script populates a varchar variable with some values concatenated from the table, and works as expected.

Part 3 of the script populates a varchar variable with some values concatenated from the table, and does not work as expected.  The only different between part 2 nd part 3 is the order by clause.

Part 4 drops the index on the table.

Part 5 repeats Part 3, but it returns the proper results now that the index is gone.

Do you think this is a bug in the Database engine?

Thanks in advance.

Part 1:


create table dbo.test_table (id int, PaidToDate_ID int,
                             PaidToDate_Code varchar(3),
                             PaidToDate_Amount money)

create index ix_test_table
   on dbo.test_table (id)

insert into test_table
  select 1, 1, 100, 1000.00

insert into test_table
  select 1, 2, 100, 1500.00

insert into test_table
  select 1, 3, 100, 300.00

insert into test_table
  select 2, 1, 200, 2000.00

insert into test_table
  select 2, 2, 200, 3400.00

insert into test_table
  select 2, 3, 200, 200.00

insert into test_table
  select 2, 1, 300, 1100.00

insert into test_table
  select 2, 2, 300, 500.00

insert into test_table
  select 2, 1, 300, 333.00

Part 2:


declare @id integer
declare @paidtodatestring varchar(max)
set @id = 2
select @paidtodatestring = ''
select @paidtodatestring = @paidtodatestring +
e.paidtodate_code + replicate(' ',(3-len(e.paidtodate_code)))+  
replicate('0',(11-len(REPLACE(CAST(e.paidtodate_amount AS VARCHAR(11)),'.','')))) + REPLACE(CAST(e.paidtodate_amount AS VARCHAR(11)),'.','')
from dbo.test_table e
where e.id = @id
select @paidtodatestring

Part 3:

declare @id integer
declare @paidtodatestring varchar(max)
set @id = 2
select @paidtodatestring = ''

select @paidtodatestring = ''
select @paidtodatestring = @paidtodatestring +
e.paidtodate_code + replicate(' ',(3-len(e.paidtodate_code)))+  
replicate('0',(11-len(REPLACE(CAST(e.paidtodate_amount AS VARCHAR(11)),'.','')))) + REPLACE(CAST(e.paidtodate_amount AS VARCHAR(11)),'.','')
from dbo.test_table e
where e.id = @id
order by e.paidtodate_id
select @paidtodatestring

Part 4:

drop index ix_test_table on dbo.test_table

Part 5:

declare @id integer
declare @paidtodatestring varchar(max)
set @id = 2
select @paidtodatestring = ''
select @paidtodatestring = @paidtodatestring +
e.paidtodate_code + replicate(' ',(3-len(e.paidtodate_code)))+  
replicate('0',(11-len(REPLACE(CAST(e.paidtodate_amount AS VARCHAR(11)),'.','')))) + REPLACE(CAST(e.paidtodate_amount AS VARCHAR(11)),'.','')
from dbo.test_table e
where e.id = @id
order by e.paidtodate_id
select @paidtodatestring


Victor Ambruso

connection string

$
0
0

Hello there, I have created a windows form using ADO.NET inside of it to write/update/delete from a table in my SQL server.

Now my porject is working fine with no problems with I use it on my PC where I created my SQL database table, but what I want not is to install this windows form on another machine which is connected to the same network at my work, but I dont know how can I change the connection string so that the other machine could access it from my machine through our work network.

Here is my connection string right now which is working fine locally:

 

Dim cn As New SqlConnection
            cn.ConnectionString = "Data Source=.;Initial Catalog=master;Integrated Security=True"

Now to access my pc at work I have to enter a user namer and password for windows to be able to be logged in, lets say my user name is operator and pass is 123, what changes do I have to do to this code to make it work? Note that I am using Visual Studio 2010 and VB.NET, thanx in advance.

BACKUP LOG cannot be performed because there is no current database backup.

$
0
0

Hi Guys,

My database backup has recently started failing with a "BACKUP LOG cannot be performed because there is no current database backup." error message. Initially I thought this was a simple fix, however running a full database backup has not resolved the issue.

Running something like this

BACKUP DATABASE [MyDB]
TO DISK = N'C:\test\full'
GO
BACKUP LOG [MyDB]
TO DISK = N'C:\test\full'
GO

Generates the following

Processed 4432 pages for database 'MyDB', file 'MyDB' on file 3.
Processed 2 pages for database 'MyDB', file 'MyDB_Log' on file 3.
BACKUP DATABASE successfully processed 4434 pages in 1.247 seconds (29.124 MB/sec).
Msg 4214, Level 16, State 1, Line 1
BACKUP LOG cannot be performed because there is no current database backup.
Msg 3013, Level 16, State 1, Line 1
BACKUP LOG is terminating abnormally.

I tried checking what the recovery status of the DB was

select last_log_backup_lsn
 from sys.database_recovery_status
where database_id = db_id('MyDB')

Which gave me a valid backup LSN.

Any ideas?

Remote Procedure call failed in SQL Server Configuration Manager

$
0
0

I have installed SQL Server 2008R2 on my Windows7 laptop successfully. However, when I open the configuration manager, the "SQL Server Services" entry shows an error message saying "The remote procedure call failed 800706be".

The full XML error is here:-

-<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
-<System>
<ProviderName="Application Error" />
<EventID Qualifiers="0">1000</EventID>
<Level>2</Level>
<Task>100</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreatedSystemTime="2012-12-08T16:26:27.000000000Z" />
<EventRecordID>33443</EventRecordID>
<Channel>Application</Channel>
<Computer>Aragorn.mollcons.local</Computer>
<Security/>
</System>
-<EventData>
<Data>wmiprvse.exe</Data>
<Data>6.1.7601.17514</Data>
<Data>4ce79267</Data>
<Data>svrenumapi100.dll</Data>
<Data>2009.100.1600.1</Data>
<Data>4bb682e9</Data>
<Data>c0000005</Data>
<Data>0003a0bf</Data>
<Data>1660</Data>
<Data>01cdd560bdd7946a</Data>
<Data>C:\Windows\sysWOW64\wbem\wmiprvse.exe</Data>
<Data>c:\Program Files (x86)\Microsoft SQL Server\100\Shared\svrenumapi100.dll</Data>
<Data>032f9a13-4154-11e2-a859-c01885d8df07</Data>
</EventData>

</Event>

The result of this is that the MSSQLSERVER instance does not display in Management Studio, so I am unable to create a new database there.


Chris Jones Mollington Consultants Limited

SQL Server 2008 R2 - Subscription Running Twice

$
0
0

Hi All,

We are running SQL Server 2008 R2 SP2 and I have a problem with a subscription which is randomly running twice. Usually around 20 seconds after the first run. There is only a single SQL Agent job and the history shows the agent job has only ran once but the logs (and the resulting output) shows the report is executed twice.

The subscription in question is set to run every 15 minutes, it runs a report and saves the result as a PDF to a UNC share. A third party utility then takes the PDF from a UNC share and sends it to a printer. It may duplicate and run twice 2 - 3 times per day.

I have tried staggering subscriptions just in case it was a locking issue with multiple subscriptions running at once but this did not help.

Any suggestions or ideas?

Jason



ODBC32 connection fails to authenticate on SQL Server

$
0
0

I ran into a weird error message yesterday when trying to connect a workstation ODBC32 to the SQL Server using Native client 10.  See message below.  I can't tell if I am facing NAT/firewall issues or SQL errors.  I have network connectivity to the server hosting the SQL Server.  I set up a new share for a folder on the C drive to test connectivity.  Workstation is Windows 7 64bit and our app is a 32 bit app.

Connection failed:

SQL State: 08001

SQL Server Error: 2146893051

[Microsoft] [SQL Server Native Client 10]SQL Server Network

Interface: The requested security package does not exist.

Slow extended event file read

$
0
0

Hey,

I'm trying to make a transition from using SQL Trace to the new extended events model, but I'm finding that reading the resulting data from a file target is extremely slow. I'm using the methods outlined here to query my .XEL file directly:

http://blogs.msdn.com/b/extended_events/archive/2010/03/09/reading-event-data-101-what-s-up-with-the-xml.aspx

...and I have near 2 GB of data from a specific session that I would like to analyze. This session was set up to track the sp_statement_complete event, filter on anything containing a 'RETURN%', and include the object_name field. Basically I'm looking for a profile of how often various functions are called in a stored proc.

I tried reading in the first of the two files produced by this session using sys.fn_xe_file_target_read, but found that it was extremely slow - as in it ran for over an hour and fifteen minutes before I gave up. Is this normal performance for the function? And is there anything that can be done to improve the performance, or are there any alternatives to this function for reading the event data?

Note: I have tried opening the data directly in SSMS, but it appears there is just too much data for it to process. I'm also open to alternatives on collecting the data - it's mainly the grouping of the object_name and aggregate of reads/writes/cpu/duration that I'm interested in, but I haven't had time yet to investigate whether there are any other targets that would provide this.

Error 40 while trying to connect SQL SSMS 2012

$
0
0

Hi guys, I Installed SQL 2012 on a windows sever 2012.

Locally the system is working fine however while trying to connect via SSMS 2012 installed on a different machine (windows 7) i encounter an interesting situation.

1. While named pipes is enabled on the SQL Server machine, the server will not appear while i browse the network looking for the server.

2. While named pipes is disabled on the sql server machine, the server will appear while i browse the network, but trying to connect will result in error 40.

all the rest, connection permissions, TCP etc. is set correctly.

any idea ?

different "estimated rows" in execution plan with "same" query

$
0
0

Hi all,

currently it's snowing outside and I wanted to optimize one of my databases. Within these optimizations I found a quite currious behaviour which I don't really understand. I have a relation which i query two times - basically - the same time. The query is as follows:

-- First query with usage of parameter
SELECT	SId, SName1
FROM	dbo.tbl_Stammdaten
WHERE	Category = @condition

-- Second query with usage of fixed value
SELECT	SId, SName1
FROM	dbo.tbl_Stammdaten
WHERE	Category = 'FRM'

SET STATISTICS XML OFF;
SET STATISTICS IO OFF;

When I have a look to the execution plan I'm wondering about ONE difference I can not really understand.

As you can see the plan is using - as expected - the created index. But... If i compare the estimated record both queris differ from each other.
The first query which is using the variable as filter has a higher value (app. 72 records) instead of 23 records which will be the estimated (and retrieved) records from the second query.

Please note: It is not a problem - I want to understand WHY the usage of the variable has a higher estimated record count.
That's the reason why i've marked this thread as a discussion thread instead of a problem.

To replay the problem you can download the t-sql script as ZIP from the following location:

http://www.db-berater.de/Files/executionplan_demo.zip


Uwe Ricken

MCITP Database Administrator 2005
MCITP Database Administrator 2008
MCITP Microsoft SQL Server 2008, Database Development

db Berater GmbH
http://www-db-berater.de
SQL Server Blog (german only)

presently running one full backup can possible again I take the another full backup ?

Viewing all 15264 articles
Browse latest View live


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