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

Mirroring issue

$
0
0
Hi,

I am trying to configure the Mirroring in 2008r2. In middle i am getting the error 1418. 
tried changing the service account. but it didn't resolved.  

Tried configure with commands below in both principal and mirror servers.

alter database abc set partner = 'tcp://node1:5022' 
alter database abc set partner = 'tcp://nod2:5022' 

for some time the database showing as synchronized and within secs the mirroring will go off. I am not able to understand what mistake i am doing. 

I tried tenet the port .. Its working. 
Also i changed the SQL Service account to administrator and domain user account.. same issue i am facing. 

above all everything i tried in Production 2008r2 servers. 

Also i tried setup same in sql2016 test servers. similar issue i am facing. please help to resolve the issue. 


Thanks,




pols


Version info reports 2017 but creates new Db in path of older version?

$
0
0

I have several previous versions of SQL installed.  Probably time to clean them all out and reinstall the single version I need on my workstation.  Regardless, I was curious why this situation is occurring when trying to create a new Db on my local instance.

SELECT @@VERSION
Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64)   Aug 22 2017 17:04:49   Copyright (C) 2017 Microsoft Corporation  Developer Edition (64-bit) on Windows 10 Pro 10.0 <X64> (Build 17134: ) (Hypervisor)

However, when I create a new db, it wants to use the file paths in the root of a previous verison

C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\

Why ?

Looking at the path of the only instance running as reported by the SQLServer MMC, I see
C:\Program Files\Microsoft SQL Server\MSSQL10.MyLocalInstance\MSSQL\Binn\sqlservr.exe

Seems like I have a 2008 still running, so then why does @@VERSION report 2017 ?

I think I see part of the problem.  This article helped
https://blog.sqlauthority.com/2016/05/30/sql-server-configuration-manager-mmc-not-create-snap-snap-might-not-installed-correctly/

Once I loaded the SQL 2017 Msc, I could see the 2017 instance I had running.  So that leaves the question as to why I cant create a new db in its path


Very High WRTELOG Wait

$
0
0

Hi,

We noticed 3 databases on a Server is having high WRITELOG wait as shown in the snippet below. 

Did some search online but could not come to a ultimate conclusion as to what  action I should be taking? 

I have the suspicion that the issue is related to VLF fragmentation because I noticed high number of VLF files (246) and the size of the .ldf file for the highest wait database has grown huge (222GB ), all other databases are between 10 to max 30GB. 

I also checked this thread but not sure if this will be a good solution? https://dba.stackexchange.com/questions/93262/biggest-wait-writelog in my case?  If yes does it require a downtime? 

The Solar Winds Database monitoring tool is showing /* Commit */ in SQL Data when the WRITELOG wait was very high. It was for about 30 minutes only.  

Please advise. 


Linked server insert problem: "Schema lock with handle 1 not found."

$
0
0
I've got a fairly lengthy custom replication/integration script that copies some data from our ERP database, hosted on SQL1 (SQL Server 2008 32-bit), to our web site database hosted on WEB1 (SQL Server 2008 64-bit). WEB1 is configured as a linked server on SQL1, using kerberos for impersonation.

When I run this script, which is kept as a stored procedure, I see a bunch of inserts happen on WEB1 via sp_cursor, and then I see a call to sp_releaseschemalock, followed by the error message "Schema lock with handle 1 not found." Since XACT_ABORT is enabled for the connection to WEB1, all the inserts get rolled back.

The strange thing is that this only started happening after upgrading SQL1 from SQL Server 2000 to SQL Server 2008. Stranger still, if I run the offending insert statements directly from Management Studio, as opposed to running the stored procedure they're contained in, they work perfectly! I've been fiddling with the linked server settings to no avail. Is there some new detail regarding linked servers that I've missed?

SQL Server detected a logical consistency-based I/O error

$
0
0

We started receiving these error messages suddenly

Error: 824, Severity: 24, State: 2.

Message
SQL Server detected a logical consistency-based I/O error: invalid protection option. It occurred during a read of page (7:8192) in database ID 2 at offset 0x00000004000000 in file 'X:\tempdb\tempdb_mssql_6.ndf'.  Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.

SQL Server detected a logical consistency-based I/O error: incorrect checksum (expected: 0x31333637; actual: 0x9c88f38a). It occurred during a read of page (7:8216) in database ID 2 at offset 0x00000004030000 in file 'X:tempdb\tempdb_mssql_6.ndf'.  Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.

An error occurred while processing the log for database 'tempdb'.  If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log.
During undoing of a logged operation in database 'tempdb', an error occurred at log record ID (239:1702646:104). Typically, the specific failure is logged previously as an error in the Windows Event Log service. Restore the database or file from a backup, or repair the database.

SQL Server must shut down in order to recover a database (database ID 2). The database is either a user database that could not be shut down or a system database. Restart SQL Server. If the database fails to recover after another startup, repair or restore the database.

------

After these messages, i had to start SQL services manually, however the errors continued

Error while allocating extent for a worktable.  Extent (6:16248) in TEMPDB may have been lost.

-------

I ran DBCC CHECKDB(tempdb)  --- no results.....

Checked with storage team for health checks, they say no issue.

However, i see many suspect_pages recorded for this DB and it even got recorded before the server crash too.

database_idfile_idpage_idevent_typeerror_count
27404401106
244044014759
2451123211
27821621
27819211
261617611935
278088118

then i had to manually delete the tempdb files and restart SQL services. Errors stopped and DB health is OK.

Trying to investigate the root cause, any pointers/advise is really appreciable. Thanks in advance.

Repair msdb database that is labeled Suspect

$
0
0

Can "Suspect" msdb be successfully repaired if there is no backup of the database?

Can you please send me the process that I should follow to repair the database?

sys.dm_os_performance_counters and query plan/memory grants

$
0
0

I'm having an issue with one of my SQL instances where some queries are in the resource_semaphore wait, waiting for available memory.  I've tracked the issue down to a query from Idera SQLdm where it's querying from sys.dm_os_performance_counters. 

I'm able to replicate the problem by this simple query:

select * from master.sys.dm_os_performance_counters
order by instance_name 

Looking at the estimated query plan for this query, the estimated number of rows to be read from the table valued function SYS_PERFORMANCE_COUNTERS is 4294970000.  If I try to run this query, it goes into a resource_semaphore wait  because it is requesting 2473104 KB of memory according to sys.dm_exec_query_memory_grants (due to the bad estimated row count) and there isn't that much available memory. 

Performing this query without the order by returns immediately and returns 2267 rows.

I've unloaded and reloaded SQL's performance counters to no avail.

I know this would be resolved (at least temporarily) by a SQL restart, but I'm hoping to find the cause.

This is a SQL 2016 SP2 (13.0.5026.0) server.

Thanks!

Mike

BULK INSERT error when the file location changed to remote share

$
0
0

I am getting following error on BULK INSERT now that the file location was changed to remote share. Before it used to a shared folder in local drive and we never ran into this issue. I have made sure both SQL server and file permissions are in place. I am running this BULK INSERT from my local PC connecting to SQL Server via SSMS.

Before when I ran this command from SSMS, it was \\SQLServer\FTP location which was a shared folder in local drive in that SQL Server but now I changed the file location to a network share \\Fileshare\FTP and have the above error but both SQL service account(domain account) and me(domain account) have elevated permission on that new location.

Any help or suggestions!!

Thanks,

--Anup



Syntax errors creating external data source and file format

$
0
0

Hey There - I'm attempting to use SQL external tables for the first time and its giving me fits. I have a set of .CSV files in ADLS that I've been used for benchmarking other Azure storage options for refreshing SSAS cubes.

I'm running SQL 2019 RC1 installed on an Azure VM:

  • Microsoft SQL Server 2019 (RC1) - 15.0.1900.25 (X64)   Aug 16 2019 14:20:53   Copyright (C) 2019 Microsoft Corporation  Enterprise Evaluation Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor)

I've installed the Polybase and Java components via SQL setup. I"ve verified that IsPolybaseInstalled=1, and I"ve tried changing "hadoop connectivity" from 0 to 1, 4, and 7.

When I execute this:

  • CREATE EXTERNAL DATA SOURCE AzureDataLakeStorage
    WITH
    (
        LOCATION='wasbs://abidata@agilebistoragedev.dfs.core.windows.net'
        ,CREDENTIAL = AzureStorageCredential
     ,TYPE =  HADOOP 
    )

I get the error:

  • Msg 102, Level 15, State 1, Line 21
    Incorrect syntax near 'HADOOP'.

It only works if I specify "TYPE = BLOB_STORAGE" even though most of the docs say HADOOP is needed for ADLS.

Also, when I execute this command:

  • create external file format ADLS_CSV_FileFormat
    WITH
    (   FORMAT_TYPE = DELIMITEDTEXT
    ,    FORMAT_OPTIONS    (   FIELD_TERMINATOR = '|'
                        ,    STRING_DELIMITER = ''
                        ,    DATE_FORMAT         = 'yyyy-MM-dd HH:mm:ss.fff'
                        ,    USE_TYPE_DEFAULT = FALSE
                        )
    );

I get the error:

  • Incorrect syntax near 'EXTERNAL'.

Any suggestions? 


Got a bug or feature request? Tell me about it at http://connect.microsoft.com. This posting is provided "AS IS" with no warranties, and confers no rights.

Transactions/s trending upward causing the CPU to trend upward.

$
0
0

Hi,

I'm investigating the performance issue on one of our SQL Server where the rate of transactions/s has suddenly increased significantly within last one week. This is causing the CPU to trend upward and we are running out of time to handle this situation. So far the CPU has increased from 20-30% (Our Normal Baseline) to above 55% and moving up daily. 

I have been struggling to pinpoint the root cause so far. I have checked for the following:

1. No Index scanning found. 
2. No changes to the server or databases. 
3. Two databases showing higher CPU/Wait time with one of them I suspect is causing this issue. 



I would appreciate if someone can guide me to the right directions.

access network share via openrowset

$
0
0

I am trying to access a blob on a network share but keep getting 

Msg 4861, Level 16, State 1, Line 3
Cannot bulk load because the file "\\server\share\1.jpg" could not be opened. Operating system error code 5(failed to retrieve text for this error. Reason: 15105).

the command is: 

select * from openrowset ( 
           bulk '\\server\share\1.jpg' 
           ,SINGLE_BLOB) x 

I can access the file from windows. I have given permissions to the share for the domain user running sqlserver 

obviously a delegation error. can a username/password be specified in the sp or openrowset? I just want access through sqlserver. I dont care how. would an assembly bypass this ? 

thanx


???

PowerShell add SQL service account to Batch Logon on remote computers, dbatools

$
0
0

      This is a good tool, https://www.powershellgallery.com/packages/dbatools/0.9.59/Content/functions%5CSet-DbaPrivilege.ps1 

.EXAMPLE 
       'sql1','sql2','sql3' | Set-DbaPrivilege -Type IFI 

if I run remotely, it doesn't work, no error msg or any msg. but it works if run locally on the sql server itself.  

firewall for domain turned off. user running the powershell is in the local admins of remote sql servers.

SQL Server 2017 Policies Location?

$
0
0

Good afternoon,

   I was wondering if anyone could tell me where the location of the best practices policies is.  These policies are supposed to come as a part of the installation process however, I cannot seem to locate them.  We used Policy-Based Management extensively in my last company and I'd like to implement here as well.  I was able to find them on SQL Server 2016 environment, but every version since the initial release has increased the number of policies and I wanted to ensure I wasn't missing any.  Any help would be greatly appreciated.


Questions about SQL Server Migration

$
0
0

Hello Experts,

I migrated the SQL Server 2014 to a new environment. The new environment operating system and SQL Server version are same as the old. --> Windows Server 2012 R2, SQL 2014

The CPU and memory are all better than the old environment.

Why SQL Server performance is slower than before. All queries are slow than before. However after about one week, the performance become fast. Everything works well.

Any ideas on this? Thanks in advance.

SQL Server Agent Job fails when using OPENROWSET

$
0
0

Hello Team,

I'm having issues with one of our SQL Server Agent Jobs that import data from an Excel sheet to a SQL Server table.

The query have

SELECT *

FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',

'Excel 12.0;Database=\\zzz\yyy\xxx\wwwt\Import.xlsx;',

'SELECT * FROM [report$]')

And it gave the error below:

Date  5/21/2018 11:33:35 AM
Log  Job History (Hours Update3)
Step ID  1
Server  SQLW16-01
Job Name  Employee Hours Update3
Step Name  Update / Insert Employee Hours in [1AAA] Table
Duration  00:00:01
Sql Severity 16
Sql Message ID 7412
Operator Emailed 
Operator Net sent 
Operator Paged 
Retries Attempted 0

Message
Executed as user: aaa\SQL_Agent.srv. Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)". [SQLSTATE 42000] (Error 7303)  OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Unspecified error". [SQLSTATE 01000] (Error 7412).  The step failed.

If I run the OPENROWSET or the SPROC that contains that, it runs perfectly fine without any issue or error. It only fails when it's being run on a Job. I also logged in to a computer as aaa\SQL_Agent.srv and it have read/write permission to the Excel file.

Anythoughts? Thank you in advance.

~Louie


Sql Server - Polybase

$
0
0

Hi ,

I am using SQL Server 2019 .I created a blank DB(not datawarehouse) in my local instance.I have a csv file in Azure Storage container and using external data source I want to read the data from csv .I used below queries to create credential,Datasource etc.

CREATE MASTER KEY ENCRYPTION BY PASSWORD = <pwd>; 
CREATE DATABASE SCOPED CREDENTIAL PolyBaseCredential WITH IDENTITY = 'PolyIdentity', SECRET = '<key from Azure>'; 
CREATE EXTERNAL DATA SOURCE PolyBaseDS WITH (TYPE = BLOB_STORAGE, LOCATION = 'wasbs://polybasetest@myblobcontainer.blob.core.windows.net/', CREDENTIAL = PolyBaseCredential ); 

When I tried creating external file format and  table,I am getting error.

CREATE EXTERNAL FILE FORMAT csvformat 
WITH ( 
    FORMAT_TYPE = DELIMITEDTEXT, 
    FORMAT_OPTIONS ( 
        FIELD_TERMINATOR = ','
    ) 
);

Msg 102, Level 15, State 1, Line 8
Incorrect syntax near 'EXTERNAL'.

CREATE EXTERNAL TABLE [Avengers]
(
        NAME [nvarchar](255) NOT NULL,
        LASTNAME [nvarchar](255) NULL,
        Email [nvarchar](255) NULL
)
WITH (DATA_SOURCE = PolyBaseDS)
GO 

Msg 102, Level 15, State 1, Line 8
Incorrect syntax near 'EXTERNAL'.

Can anyone help please? I tried creating Data source with Type= HADOOP but it threw error -incorrect syntax near Hadoop.So I tried TYPE=BLOB_STORAGE.

Non-yielding Scheduler

$
0
0

I am on SQL 2014 SP2, no CU, latest GDR.

I checked and SP3 looks like fixed this (here https://support.microsoft.com/en-ca/help/4338890/sql-server-appears-unresponsive-and-non-yielding-scheduler-error-occur) .

Is there anything else I should do before I deploy SP3? I only had one incident of this in 1 year.

Error that I got

DoMiniDump () encountered error (0x80004005) - Unspecified error
Process 67:0:2  Worker 0x00000009AB20E160 appears to be non-yielding on Scheduler 0. Approx Thread CPU Used: kernel 0 ms, user 72521 ms. Process Utilization 25%. System Idle 70%. 
External dump process return code 0x20000001.
External dump process returned no errors.

[INFO]          Identity             Begin               End |        State                  Result     Error  Speculate   Prepared LazyCommit   ReadOnly |      Transaction         Database          ThreadId |   ReadSet  WriteSet  ScanSet Savepoint LogSizeRq | CommitDep TotalComm       Dependent 0       Dependent 1       Dependent 2       Dependent 3       Dependent 4      Dependent 5       Dependent 6       Dependent 7 |            Area  Location |
***Unable to get thread context for spid 0
* *******************************************************************************
*
* BEGIN STACK DUMP:
*   10/24/19 10:07:00 spid 3108
*
* Non-yielding Scheduler
*
* *******************************************************************************

Thank you,

How does SQL allocate indexes with nvarchar in the index key column

$
0
0

Fellow SQLers.

I am trying to find out what SQL does internally with this scenario and cannot find an answer to my liking in BOL or other places.

SQL 2016

Lets say you have a nvarchar(30) field that you need to have an Non Clustered Index on.

That internally is 60 bytes.

Lets say I am talking about a 12 byte record(althought it does not matter).

Does SQL actually RESERVE 60 bytes for the index row (plus overhead for nvarchar)  but uses only the actually Unicode size for the data and leave the remaining space as unused?

For example

Reserved 60, used 24, unused 36. I know this is not exact.

Is this correct?

Thanks

MG

DBA Questions

$
0
0

Hello all,

I faced following DBA questions which I could not answer. Please help.

1. Due to which db setting the log file size does not reduce on running shrinkfile command just after making the log file size          100 gb or so due to heavy transaction ?

2. What is the reason of persistent db restoring activity even after it is shown that the restore is 100% ?

3. What to do if master db crashes ?

4. Can we restore msdb ?

5. How to check the versions of all the db servers in a network from ssms at once ?

6. How to transfer users and jobs from one server to another ?

7. What is file sharing in alwayson ?

Tempdb space issue

$
0
0

Hi All,

One of the prod env, we are seeing high utilization of Tempdb and eventually hitting Tempdb drive full.

We increased the drive size by 100 Gb twice but still we are seeing same drive full errors due to tempdb every weekend. We have captured the usage using sp_whoisactive and provided the details to dev team to optimize their queries but there is no action taken by that team.

DBA team, has created an alert of Tempdb usage and if free % less than 20, we get the Tempdb data file usage per file and eventually we had to kill those txns. Again, this is due to specific txns which are run over the weekends.

Now, what I want to know is , as a DBA what should be done to avoid such issues apart from keep increasing the Tempdb drive size each and every time. Also, trying to understand how much should be the Tempdb drive size ?


Thanks,

 Sam

Viewing all 15694 articles
Browse latest View live