Quantcast
Channel: SQL Server Database Engine Forum
Viewing all 15872 articles
Browse latest View live

Finding unused tables in a database

$
0
0

Normally app developers give this info, but i as a DBA am being asked for this unusual request:

The database is a on a azure elastic pool, need to know the 'unused tables in the database'

Please let me know, thanks.


D


error in the log

$
0
0

We recently got message in sql server log like below: 

What could be wrong:

SQL Server has encountered 1 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [F:\MSSQL\LOG\MBAM Recovery and Hardware_Primary.ldf] in database id 10.  The OS file handle is 0x0000000000001008.  The offset of the latest long I/O is: 0x0000009d303600.  The duration of the long I/O is: 32629 ms.

Message
FlushCache: cleaned up 8690 bufs with 7095 writes in 211148 ms (avoided 5100 new dirty bufs) for db 12:0

Message
average writes per second:  33.60 writes/sec 
            average throughput:   0.32 MB/sec, I/O saturation: 100, context switches 332

SQL Server has encountered 1 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [F:\MSSQL\LOG\SUSDB_log.ldf] in database id 11.  The OS file handle is 0x0000000000000FF4.  The offset of the latest long I/O is: 0x00000016ac0800.  The duration of the long I/O is: 45448 ms.

Message
last target outstanding: 19200, avgWriteLatency 0

SourceServer

Message
Long Sync IO: Scheduler 3 had 1 Sync IOs in nonpreemptive mode longer than 1000 ms

Message
FlushCache: cleaned up 24141 bufs with 16849 writes in 181911 ms (avoided 25301 new dirty bufs) for db 12:0

Message
average writes per second:  92.62 writes/sec 
            average throughput:   1.03 MB/sec, I/O saturation: 101, context switches 458
Message
last target outstanding: 19200, avgWriteLatency 0

Message
A time-out occurred while waiting for buffer latch -- type 3, bp 000001BDA73F7740, page 1:42954663, stat 0x10b, database id: 12, allocation unit Id: 72057622850764800, task 0x000001BD4C033468 : 0, waittime 300 seconds, flags 0x100000001a, owning task 0x000001BD4AC2D468. Not continuing to wait.

Sourcespid19s

Message
Error: 845, Severity: 17, State: 1.

Message
Time-out occurred while waiting for buffer latch type 3 for page (1:42954663), database ID 12.

 

Message
A time-out occurred while waiting for buffer latch -- type 3, bp 000001BDA73F7740, page 1:42954663, stat 0xb, database id: 12, allocation unit Id: 72057622850764800, task 0x000001B109AE48C8 : 0, waittime 300 seconds, flags 0x100000001a, owning task 0x000001BD4AC2D468. Not continuing to wait.

Message
One or more recovery units belonging to database 'ourdbname' failed to generate a checkpoint. This is typically caused by lack of system resources such as disk or memory, or in some cases due to database corruption. Examine previous entries in the error log for more detailed information on this failure.


Message
A time-out occurred while waiting for buffer latch -- type 3, bp 000001BDC780B580, page 1:42954644, stat 0xb, database id: 12, allocation unit Id: 72057622850764800, task 0x000001BD4C043088 : 0, waittime 300 seconds, flags 0x100000001a, owning task 0x000001BD4AC0CCA8. Not continuing to wait.


Thanks

Issues with Polybase accessing another on-prem SQL Server

$
0
0

Hello,

I'm putting together a proof-of-concept for Polybase to share with my team.  Polybase is installed on a newly built SQL2019 RTM server.  One of the two remote data sources I've created so far is an on-prem SQL 2014 server.  I used Azure Data Studio to create a external table pointing to a view on the remote server - this view should return a bit over 500K rows.

A select * from the view returns: 

Msg 105082, Level 16, State 1, Line 54
105082;Generic ODBC error: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: An existing connection was forcibly closed by the remote host.
 Additional error <2>: ErrorMsg: [Microsoft][ODBC Driver 17 for SQL Server]Communication link failure, SqlState: 08S01, NativeError: 10054 .
OLE DB provider "MSOLEDBSQL" for linked server "(null)" returned message "Unspecified error".
Msg 7421, Level 16, State 2, Line 54
Cannot fetch the rowset from OLE DB provider "MSOLEDBSQL" for linked server "(null)". .

If If I run a select top 20 *, it fails with the same error.  

Select top 19 * works fine.

If I specify the columns to return, I can get more rows returned.  For example, if I select 8 columns from the view, and do a select top 109, it works, while a select top 110 of the same 8 columns fails.

If I remove one of these columns, more rows are returned... select top 125 works, but top 126 fails.

I have a second remote data source set up in Polybase - this one links to a SQL 2016 instance hosted in a private cloud.  I can query a large table (over 600K rows) via an external table and all 600K+ rows are returned.

Any ideas to help me troubleshoot?

General index question

$
0
0

Just a general question on indexes. If sql server lists the following indexes as missing indexes, should you create both index one and index two, or just index two?    With it being the same 3 initial columns, I would think you would just create index two.

 

columns for recommended index one

AAA

BBB

CCC

columns for recommended index two

AAA

BBB

CCC

DDD

Maintenance Plan

$
0
0

Hi All,

On one of our backup maintenance plan, the DB Backup task is configured to backup & also check the backup integrity.

Our management wants to know if it was added to perform backup integrity when the plan was created or later it was added.

Is there a way to check? If yes, can you please let me know.


In my Actual Execution Plan, why is the actual rows number 3280% of Estimated rows and does it matter?

$
0
0

SQL Server 2016. My query is against a Fact table with 4.7 billion rows. It has a clustered columnstore index and 3 NC row store indices. The query is using one of those which makes sense in this instance.

I'm joining the Fact to a temp table containing the required account keys. There are 11 of those. The NC index has the account key as the leading part and is covering.

The index was built about 4 hours ago and the table has not changed, since.

This is the first part of the plan:


Takes several minutes to run which is not really acceptable for one query in a complex SSRS report for end-users.

I'm not clear on which is the best of the JOINs for this set of data - perhaps the Nested Loops is not suitable for the 11 account keys being joined to the 200 million transaction rows?

Apart from Account Key, the other part of the JOIN is that the Transaction Date falls within a range of 24 months. The table is partitioned on transaction date with 1 month per partition. I organised the columnstore by first creating a clustered index on TransactionDate then created the columnstore with Drop Existing on which was a tip I found to help maximise segment elimination when querying with Transaction Date. Not that this is relevant to the current query, I suppose.

I have added an OPTION( RECOMPILE ) to the SELECT in case that helped. The actual number of rows returned varies enormously from this our largest merchant to the smallest.

So, can anyone suggest why the stats don't seem to be helping get the row count right? And is Nested Loops the best type of join, here?

Nick Ryan MIS Programmer Analyst, ANZ Bank


No SQLPackage.exe in SQl Server 2019 ?

$
0
0

Hi,

Our installer are failing as they are unable to find SQLPackage.exe on SQL Server 2019. Copied DAC folder of 2012 and put it in 150 folder, it didn't work.

Pls help...

igraph png not working on SQL Server 2019

$
0
0

Hi,

I made some tests with Graph Databases and was trying to use R services do create an image file of the graph. I'm not an R specialist but I was able to write an R script to create the image, it works very well on SQL Server 2017.

The R script:

exec sp_execute_external_script @language = N'R', 
@script = N'
require(igraph)
g <- graph.data.frame(graphdf)
V(g)$label.cex <- 2
png(filename = "c:/R/plot1.png", height = 1200, width = 1200, res = 100); 
plot(g, vertex.label.family = "sans", vertex.size = 40)
dev.off() ', 
@input_data_1 = N'select LikeMember.MemberName as LikeMember,    LikedMember.MemberName as LikedMember         from dbo.ForumMembers as LikeMember,  dbo.ForumMembers as LikedMember,  Likes
        where Match(LikeMember-(Likes)->LikedMember)', 
@input_data_1_name = N'graphdf'
GO

It works perfectly in SQL Server 2017 but I couldn't make it work in SQL Server 2019. The error message is:

Error in png(filename = "c:/R/plot1.png", height = 1200, width = 1200,  : 
  unable to start png() device
Calls: source -> withVisible -> eval -> eval -> png
In addition: Warning messages:
1: In png(filename = "c:/R/plot1.png", height = 1200, width = 1200,  :
  unable to open file 'c:/R/plot1.png' for writing
2: In png(filename = "c:/R/plot1.png", height = 1200, width = 1200,  :
  opening device failed

Error in execution.  Check the output for more information.
Error in eval(ei, envir) : 
  Error in execution.  Check the output for more information.
Calls: runScriptFile -> source -> withVisible -> eval -> eval -> .Call
Execution halted

Although the error message seems obvious, I already checked the permissions on the folder, the user of the services (SQL Server and Launchpad) and even used the audit over the folder but could not identify how to solve this problem.

Any idea?

Thank you!

Dennes



why do dm_db_index_usage_stats have two entries for each index

Unable to delete replication after restored a database with replication

$
0
0

Hi There,

Backup and restored a database from another SQL server which had Replication set up. After successfully restored database, the replication had carried forward, now wouldn’t be able to remove the replication setting such as delete subscription or publication, even wouldn’t be able to delete the database. The replication can be considered as orphan replication setup, how can I delete these settings?

Cheers,

Tony


Cheers, Tony

Where to find SQL Server 2014 Developer edition download?

$
0
0

Hi!

Does anyone know if there is a link to download SQL Server 2014 developer edition?

I need to repair an instance but we no longer have a copy of the media..

Thanks,

Zoe

Error Access to the path is denied. (mscorlib) When trying to open new query window

$
0
0

SQL server 2012 SSMS 2017

Hi If I click the new query button or right click db and choose new query I get this message .

TITLE: Microsoft SQL Server Management Studio
------------------------------
Access to the path is denied. (mscorlib)

I have not had this problem previous to today?


Windows live mail

$
0
0

After a Windows update last night all my files in livemail have been orphaned from the message I got.

How do I recover please? I need clear instructions please. Thank you

Non clustered column store index major bug in SQL server 2016 SP1 Enterprise Edition

$
0
0

Our stage table holds 130 + columns with 1 billion 430 million rows with partition with service date. we created non clustered column store index, it took 36 hours for its completion. after creating the index the select count_big(col_name) from table shows 40 billion as row count, we tested this by sp_space used, sys.indexex table, right click and properties the table all shows the 1 billion 430 million rows. Before index creation also we count the table after 45 minutes execution it says the 1 billion 430 million. estimated number of rows in non clustered column store also shows 1 billion 430 million rows, but count shows very strange result. 

Below are the execution plan details

Column store index scan (Non clustered)
scan columnstore index, entirely or only a range.

Physical operation : columnstore index scan
logical operation : index scan
Estimated execution mode : Batch
Storage : ColumnStore
Estimated I/O Cost:0.05625
Estimated Operator Cost : 8.74159(41%)
Estimated SubtreeCost : 8.74159
Estimated CPU Cost:8.68534
Estimated Number Of Executions:1
Estimated Number Of Rows: 1262930000
Estimated Row Size: 27B
Partitioned : True
Ordered: False
Node ID : 5

In the GUI it is displayed like this

select cost 0% <———Parallelism(Gather Streams) Cost 0% <——-Compute Scalar Cost : 0% <—— Hash Match Aggregate Cost(59%) <——- Columnstore index scan cost 55%.


SQL error 5171

$
0
0
I'm getting an error while operating the SQL server. It displays as SQL server error 5171. I'm not able to resolve this error. Please, somebody, help me get out of this.

Database Status: Suspect vs Recovery Pending.

$
0
0

what's the different between database status Suspect vs Recovery Pending. ???

what's are the different causes for both Suspect vs Recovery Pending. ???

questions about cutom indexes on replication target tables

Sql Agent service stop notification

$
0
0

I am trying setup automatic job using the windows task scheduler to notify when Sql Agent service stopped but somehow i am not getting alert when i am manually stopping but when i run the job manually then i am getting the email notification.

I think it should be right windows event trigger setting bu i am not sure which one i should setup the triggering action.

I need notification when sql agent service stopped.

If someone can help me out?

 
I am calling PowerShell script using batch script.

Batch Script:

powershell.exe -command C:\Users\ServiceCheck.ps1

Powershell Script (ServiceCheck.ps1):

$servers=get-content "C:\Users\servers.txt"

foreach($server in $servers)

{

# go to each server and return the name and state of services

# that are like "SQLAgent" and where their state is stopped

# return the output as a string

$body=get-wmiobject win32_service -computername $server |

select name,state |

where {($_.name -like "SQLAGENT*" -or $_.name -like "SQL*AGENT") `

-and $_.state -match "Stopped"} |

Out-String

if ($body.Length -gt 0)

{

#Create a .net mail client

$smtp = new-object Net.Mail.SmtpClient("mail.myinc.com")

$subject="SQL Agent is down on " + $server

$smtp.Send("pds0809@myinc.com", "pds0809@myinc.com", $subject, $body)"message sent"

}

}


How to Configure Database Mail Using Database Engine Service Credentials

$
0
0

I have jobs set up in SQL Server Agent that use sp_send_dbmail to email employees some reports on a schedule. Today I discovered the reports were not going out due to a password change on my credentials. I updated my account for Database Mail under Basic authentication and the reports are emailing once again.

[Manage Existing Account screen shot]

I began to enter a help ticket to our IT department to see if I could get an account with a non-expiring password, but then I saw the option above Basic authentication to use the Database Engine service credentials and thought this would be the way to go. When I choose this option, I get the same error I was getting when my password was incorrect:

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2019-11-06T12:47:35). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM).  )

My understanding is that the service credentials being used are the virtual account for SQL Server under SQL Server Services, which appears to be set up correctly.

[2 SSCM screen shots]

 So why does Database Mail not authenticate properly and send the email as it does when I use Basic authentication?


SQL Server 2019 Behavior change with scope of SET IDENTITY_INSERT ON/OFF

$
0
0

We are migrating to SQL Server 2019 RTM version and noticed that one of our stored procs that uses SET IDENTITY_INSERT ON/OFF statements is failing which works properly in SQL 2017 and earlier.  Even changing compatibility level to SQL 2017 does not work the same way in SQL 2019.  This looks like a bug/behavior change that is not documented anywhere.

We have lots of customers running earlier versions of our product with this stored procs that we cannot afford to change but still want to migrate to SQL 2019 and now this has become a show stopper for our SQL 2019 migrations.

Can this bug be fixed as a patch quickly?

How to reproduce the behavior.

CREATE PROC proc_inner
AS
    BEGIN
        SET IDENTITY_INSERT [#TMP_MESSAGE] ON;
        INSERT INTO [#TMP_MESSAGE]
        (DCORP, 
         ENTITYKEY, 
         SEQNO, 
         MESSAGE
        )
               SELECT 'test', 
                      1, 
                      1, 
                      'bdkfsjk';
        SET IDENTITY_INSERT #TMP_MESSAGE OFF;
    END;
GO

CREATE PROC proc_outer
AS
    BEGIN
        IF OBJECT_ID('TEMPDB..[#TMP_MESSAGE]') IS NULL
            BEGIN
                CREATE TABLE [#TMP_MESSAGE]
                (DCORP     CHAR(10), 
                 ENTITYKEY INT, 
                 SEQNO     INT IDENTITY(1, 1), 
                 MESSAGE   VARCHAR(8000)
                );
        END;
        EXEC proc_inner;
        SELECT *
        FROM #TMP_MESSAGE;
    END;
GO

EXEC proc_outer; -- this statement fails on SQL 2019 

In SQL 2019 - you receive error

Msg 544, Level 16, State 1, Procedure proc_inner, Line 5 [Batch Start Line 36]
Cannot insert explicit value for identity column in table '#TMP_MESSAGE' when IDENTITY_INSERT is set to OFF.

(0 rows affected)

In SQL 2017 and earlier, the same statement works properly.


Viewing all 15872 articles
Browse latest View live


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