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

Express to full version of SQL

$
0
0

Hello and thanks for taking time to read this post.

I am no SQL pro.  I barely know enough to navigate the management studio.  I primarily work in desktop support and provide some server maintenance services to my customers. 

I'm now faced with an issue with a medical clinic client regarding their EMR (Accuro) SQL DB as they have run out of room.  I did not set this up initially but rather inherited the client from a peer who moved on.  After some probing I discovered the license was for SQL express and limited to a 10GB DB.  So this DB needs room to grow.  I expect we'll need to migrate/upgrade the license but I have no idea how to carry it out (much less the confidence).

So I'm on the hunt for information about this upgrade process and likely assistance (paid of course).


Too many sleeping session in SQL Server

$
0
0

Hi,

While checking database health I found for a particular user 'alex' there are 600 sessions in 'sleeping' status and many of these are 1 months old. I need to know-

1) What does 'sleeping' session stand for?

2) Does sql server does not close connection automatically after the execution done?

3) Do I need to kill the sleeping session? If not, will it make any trouble in future?

Retrieve the data from large XML files

$
0
0

Hi everybody,

One of my clients wants to get the data of large XML files (about 500 Mo) and spread them into different SQL Server tables.
I tried with OPENROWSET. I insert the file content in a xml field and try to query it, but it's not effective when the file is large and contained too many different nodes.

What would be the most effective way? (process the file with another language (use C# SQLBulkCopy for instance...))?

Thanks for your help!

Pete

MAXDOP and CPU utilization

$
0
0

I m using SQL server 2016 Enterprise edition with Alwayson. Our server have 8 CPU and now i have seen many query using all 8 CPU (parallelism) , i have change the maxdop server level to 4 but i can see still all my 8 CPU has been utilized by the SQL Server. By right if i set maxdop 4, only 4 cpu must be utilized by SQL server and not 8 right?

Kindly advice

CXCONSUMER & PREEMPTIVE_XE_DISPATCHER wait event in sql server

$
0
0

Hi,

We are observing average cpu usage moe than 60% from last 7 days whereas previously for 1 year average cpu was 30%. While checking I found CXCONSUMER & PREEMPTIVE_XE_DISPATCHER wait event as 47% & 26% respective. 

We do statistics update and index rebuilding every night. There is also no major fragmentation in index. 

Please let me know if the cpu high usage has relation with this wait event and what action need to be taken?

Regards

Arif





problem with link server connection

$
0
0

SQL server instance A on ServerA:  A is sql server 2017 with CU 14 

SQL server instance B on ServerB: B is sql server 2017 with CU 16

On server A, I created a linked server--- connect from SQL server A to sql server B.

I get one error log today: 

Date5/10/2020 7:55:01 AM
LogJob History (JobA)

Step ID4
ServerA
Job Namejob1
Step Namestep4
Duration00:10:40
Sql Severity16
Sql Message ID7412
Operator Emailed
Operator Net sent
Operator Paged
Retries Attempted0

Message
Executed as user: domain\user1. TCP Provider: The semaphore timeout period has expired. [SQLSTATE 07008] (Error 121)  OLE DB provider "SQLNCLI11" for linked server "ServerB" returned message "Communication link failure". [SQLSTATE 01000] (Error 7412).  The step failed.

What's the problem? How to fix this issue?

Application using SQLSERVER 2019 Std Cluster AlwaysOn AG

$
0
0

hi community:

   Our company is looking into SQL AlwaysON AG for critical applications. We were using SQL AlwaysOn FCI all the time and were quite happy with it.  

Application has to get authenticated when it reaches any user databases. I understand that SQL AO AG only deals with

User databases. So how would application access DB when it gets failed over to another node   ? Master db is not in any

AG. 

Thanks

Hui

failed: run sql server agent job to call store procedure on another server

$
0
0

Sql server A, Sql server B, oracle database server  C

Now,

SQL server B load data from oracle database server C to sql server B's database BB, using store procedure Load_oracle

On SQL server A,

I create link server to connect SQL server B. Then run following T-sql to load from oracle database server C to sql server B's database BB

I use following t-sql on sql server A

DECLARE @RunStoredProcSQL VARCHAR(1000);
SET @RunStoredProcSQL = 'EXEC [B].[dbo].[Load_oracle]';
EXEC (@RunStoredProcSQL) AT [B];

It is successful. Takes 5 minutes to complete store procedure Load_oracle running on sql server B.I execute sql server query window under SSMS: paste those coding and execute

However, after I createed a job under sql server agent on server A, here is screenshot. 



I ran the job on Server A

I get failure message:

Executed as user: domain\user. Cannot create an instance of OLE DB provider "OraOLEDB.Oracle" for linked server "xxxx"(oracle server name). [SQLSTATE 42000] (Error 7302).  The step failed.

I checked providers under linked server: no OraOlEDB.oracle .

What's the problem? and how to fix it? It is successful under sql server query windows under sql server management studio?-- I past the code and run. But fail when I run these code though sql server agent job. Why?




The SQL server JOBS that got created (Using complex Views) processing is very slow in SQL Server 2016 Compatibility then SQL 2012 Compatibility

$
0
0
The SQL server JOBS that got created (Using complex Views) processing is very slow in SQL Server 2016 Compatibility then SQL 2012 Compatibility

DBCC shrinkdatabase not able to release allocated unused space

$
0
0

I am trying to release allocated free space from my database. Cuurent state of my database 



I was trying to run DBCC SHRINKDATABASE (N'DBName') command and it will end up with following message. I want to reduce this allocatedUnused Space to zero(almost). Any help appropriated. 

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

DBCC SHRINKDATABASE: Page 1:6914608 could not be moved because it is an off-row persistent version store page. Page holdup reason: Unknown. Page holdup timestamp: -1.


Let us TRY this |


My Blog :: http://quest4gen.blogspot.com/

from sql server agent job to call a sql job on linked server

$
0
0

SQL server A and sql server B.

SQL server A create link server to sql server B

Database AA on sql server A.

backupAA job under sql server agent on SQL server A--- it is backup database AA to \\SQLServerB\backup\AA.bak(local share folder on sql server B)

and then call restoreAA job under sql server agent on SQL server B--- restore AA to datbase AA on sql server B

Before, all working fine.

Today, backupAA job failed on SQL server A.

Error message:

 Executed as user: domain\user. Cannot open backup device 'X:\Backup\AA.bak'. Operating system error 32(The process cannot access the file because it is being used by another process.). [SQLSTATE 42000] (Error 3201) RESTORE DATABASE is terminating abnormally. [SQLSTATE 42000] (Error 3013). The step failed.

What is the problem? how to fix it?

Backing up database on shared folder

$
0
0

Hi everyone,

I wanted to backup my database on shared folder. I changed log on account of SQL server to administrator, and granted to admin access to shared folder. 

However, when I try following command:

backup database %db% to disk = '\\shared_folder\DB.bak'

It gives me error incorrect user name or password. I double checked user name and password and it is correct.

When I try to xp_cmdshell it gives me error that user doesn't have access.

What can be source of this issue?

Regards,

Yerkhan

Corrupt SQL database

$
0
0

I am having an issue with a corrupt SQL database. This database runs functions for one of our products and this corruption is causing some tasks to not run. I have run the following commands against the database but each has failed with errors.

dbcc checkdb (varonis,repair_rebuild) and dbcc checkdb (varonis,REPAIR_ALLOW_DATA_LOSS)

Below is a small portion of the error log from the repair_build command; the error log is to large to paste all of it into the window.

DBCC results for 'varonis'.

Msg 8905, Level 16, State 1, Line 1

Extent (1:300552) in database ID 9 is marked allocated in the GAM, but no SGAM or IAM has allocated it.

Repairing this error requires other errors to be corrected first.

Msg 2576, Level 16, State 1, Line 1

The Index Allocation Map (IAM) page (1:1902450) is pointed to by the previous pointer of IAM page (1:2125788) in object ID 0, index ID -1, partition ID 0, alloc unit ID 72057961241706496 (type Unknown), but it was not detected in the scan.

The repair level on the DBCC statement caused this repair to be bypassed.

Msg 8906, Level 16, State 1, Line 1

Page (1:2125170) in database ID 9 is allocated in the SGAM (1:2044929) and PFS (1:2119056), but was not allocated in any IAM. PFS flags 'MIXED_EXT ALLOCATED 0_PCT_FULL'.

Repairing this error requires other errors to be corrected first.

Msg 8906, Level 16, State 1, Line 1

Page (1:2125171) in database ID 9 is allocated in the SGAM (1:2044929) and PFS (1:2119056), but was not allocated in any IAM. PFS flags 'MIXED_EXT ALLOCATED 0_PCT_FULL'.

Repairing this error requires other errors to be corrected first.

Msg 8906, Level 16, State 1, Line 1

Page (1:2125172) in database ID 9 is allocated in the SGAM (1:2044929) and PFS (1:2119056), but was not allocated in any IAM. PFS flags 'MIXED_EXT ALLOCATED 0_PCT_FULL'.

Repairing this error requires other errors to be corrected first.

Msg 8906, Level 16, State 1, Line 1

Page (1:2125173) in database ID 9 is allocated in the SGAM (1:2044929) and PFS (1:2119056), but was not allocated in any IAM. PFS flags 'MIXED_EXT ALLOCATED 0_PCT_FULL'.

Repairing this error requires other errors to be corrected first.

Msg 8906, Level 16, State 1, Line 1

Page (1:2125331) in database ID 9 is allocated in the SGAM (1:2044929) and PFS (1:2119056), but was not allocated in any IAM. PFS flags 'MIXED_EXT ALLOCATED 0_PCT_FULL'.

Repairing this error requires other errors to be corrected first.

CHECKDB found 7 allocation errors and 0 consistency errors not associated with any single object.

Table error: table 'sys.sysschobjs' (ID 34). Index row in index 'nc2' (ID 3) does not match any data row. Possible extra or invalid keys for:

Msg 8956, Level 16, State 1, Line 1

Index row (1:76905:21) with values (name = 'DF__TMP_SDT_4__inode__3A9B7C2E' and nsid = 1 and nsclass = 0 and id = 983268398) pointing to the data row identified by (id = 983268398).

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

Msg 8955, Level 16, State 1, Line 1

Data row (1:198310:3) identified by (id = 313466131) with index values 'name = 'DF__TMP_SDT_4__HResu__12AF1D13' and nsid = 1 and nsclass = 0 and id = 313466131'.

Msg 8952, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Index row in index 'nc2' (ID 3) does not match any data row. Possible extra or invalid keys for:

Msg 8956, Level 16, State 1, Line 1

Index row (1:628785:26) with values (name = 'DF__TMP_SDT_4__times__49DDBFBE' and nsid = 1 and nsclass = 0 and id = 1239269310) pointing to the data row identified by (id = 1239269310).

Msg 8952, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Index row in index 'nc2' (ID 3) does not match any data row. Possible extra or invalid keys for:

Msg 8956, Level 16, State 1, Line 1

Index row (1:628786:17) with values (name = 'DF__TMP_SDT_4__CS_Na__47F5774C' and nsid = 1 and nsclass = 0 and id = 1207269196) pointing to the data row identified by (id = 1207269196).

Msg 8952, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Index row in index 'nc2' (ID 3) does not match any data row. Possible extra or invalid keys for:

Msg 8956, Level 16, State 1, Line 1

Index row (1:628786:27) with values (name = 'DF__TMP_SDT_4__FileN__3B8FA067' and nsid = 1 and nsclass = 0 and id = 999268455) pointing to the data row identified by (id = 999268455).

Msg 8952, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Index row in index 'nc2' (ID 3) does not match any data row. Possible extra or invalid keys for:

Msg 8956, Level 16, State 1, Line 1

Index row (1:628786:28) with values (name = 'DF__TMP_SDT_4__FileN__3C83C4A0' and nsid = 1 and nsclass = 0 and id = 1015268512) pointing to the data row identified by (id = 1015268512).

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

Msg 8955, Level 16, State 1, Line 1

Data row (1:1264219:33) identified by (id = 716943566) with index values 'name = 'DF__TMP_SDT_4__inode__2ABBB0CE' and nsid = 1 and nsclass = 0 and id = 716943566'.

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

Msg 8955, Level 16, State 1, Line 1

Data row (1:1378391:16) identified by (id = 105465390) with index values 'name = 'DF__TMP_SDT_4__IsCas__0649462E' and nsid = 1 and nsclass = 0 and id = 105465390'.

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

Msg 8955, Level 16, State 1, Line 1

Data row (1:1404013:26) identified by (id = 2108948525) with index values 'name = 'DF__TMP_SDT_4__Creat__7DB4002D' and nsid = 1 and nsclass = 0 and id = 2108948525'.

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

Msg 8955, Level 16, State 1, Line 1

Data row (1:1428566:32) identified by (id = 748943680) with index values 'name = 'DF__TMP_SDT_4__FileN__2CA3F940' and nsid = 1 and nsclass = 0 and id = 748943680'.

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

Msg 8955, Level 16, State 1, Line 1

Data row (1:1623836:12) identified by (id = 233465846) with index values 'name = 'DF__TMP_SDT_4__Share__0DEA67F6' and nsid = 1 and nsclass = 0 and id = 233465846'.

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

Msg 8955, Level 16, State 1, Line 1

Data row (1:1684344:19) identified by (id = 41465162) with index values 'name = 'DF__TMP_SDT_4__FWTim__0278B54A' and nsid = 1 and nsclass = 0 and id = 41465162'.

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

Msg 8955, Level 16, State 1, Line 1

Data row (1:1799058:44) identified by (id = 1500946359) with index values 'name = 'DF__TMP_SDT_4__times__59769FB7' and nsid = 1 and nsclass = 0 and id = 1500946359'.

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

Msg 8955, Level 16, State 1, Line 1

Data row (1:1927776:4) identified by (id = 393466416) with index values 'name = 'DF__TMP_SDT_4__SymDi__1773D230' and nsid = 1 and nsclass = 0 and id = 393466416'.

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

Msg 8955, Level 16, State 1, Line 1

Data row (1:1927779:7) identified by (id = 521466872) with index values 'name = 'DF__TMP_SDT_4__Creat__1F14F3F8' and nsid = 1 and nsclass = 0 and id = 521466872'.

Msg 8951, Level 16, State 1, Line 1

Table error: table 'sys.sysschobjs' (ID 34). Data row does not have a matching index row in the index 'nc2' (ID 3). Possible missing or invalid keys for the index row matching:

CHECKDB found 7 allocation errors and 327 consistency errors in database 'Varonis'.

repair_allow_data_loss is the minimum repair level for the errors found by DBCC CHECKDB (Varonis, repair_rebuild).

Msg 596, Level 21, State 1, Line 0

Cannot continue the execution because the session is in the kill state.

Msg 0, Level 20, State 0, Line 0

A severe error occurred on the current command. The results, if any, should be discarded

A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.) (Microsoft SQL Server, Error: 10054)

$
0
0

SQL server 2019 has been installed in Linux (ubuntu) machine .  When i am trying to connect the SQL instance  eaither in Linux machine nor in the Windows SSMS tool , i am encountering the error shown in the above snapshot. 

Can you please help me resolve this . 

thank you 

hemadribabu


hemadri

a question about run remote store procedure on link server

$
0
0

SQL server A, SQL server B and Oracle server C

sql server A: created a link server B to connect to sql server B

SQL server B: created a link server C to connect to oracle server C

On sql server B:stored procedure under databaseBB-databaseBB.dbo.loaddatafromoracleC  load data from oracle to databaseBB by openquery

On SQL server A:I run exec SQLserverB.databaseBB.dbo.loaddatafromoracleC under open query window.Successfully load data from oracle C to database BB on sql server B.

But also on SQL server A, I add 'exec SQLserverB.databaseBB.dbo.loaddatafromoracleC' to sql server agent job . Failed after run the sql server agent job. I get the following error message "Executed as user: domain\user. Cannot create an instance of OLE DB provider "OraOLEDB.Oracle" for linked server "Oracle Server C". [SQLSTATE 42000] (Error 7302).  The step failed"

It doesn't look like sql server agent account permission issue from the error message. Do I have to create a link server from sql server A to Oracle C? SQL server A calls SQL server B store procedure to run-- this store procedure load data from oracle C. So I don't think I need to create a link server connection from SQL server A to Oracle C.

What is the problem? How to fix it? 





SQL Server 2019 Linux in Docker - RETAIL ASSERT During Restore Operation

$
0
0

Hi there,

Looking for some help with an issue we are facing. Situation is that we are using container instances in Azure to run very short lived instances of SQL Server 2019 in a Linux Docker image. I know just there already there are many moving parts and this may not necessarily be the most correct spot for assistance, if not please direct me as I am a bit stuck at the moment on where to go for support.

As for our problem: Sometimes, seemingly more often with larger databases, we are hitting an issue where SQL Server will hard crash with a RETAIL ASSERT error. The instance is not recoverable at this point. 

Full error details:

This program has encountered a fatal error and cannot continue running at Tue May 12 17:16:29 2020
The following diagnostic information is available:

         Reason: 0x00000004
        Message: RETAIL ASSERT: Expression=(!"A timeout or deadlock was encountered while waiting" " for a thread to terminate/suspend/resume.") File=NtumWaiter.cpp Line=610
    Stack Trace:
                 file://package4/windows/system32/sqlpal.dll+0x000000000033D3A7
                 file://package4/windows/system32/sqlpal.dll+0x000000000033CAEF
                 file://package4/windows/system32/sqlpal.dll+0x0000000000206DAA
                 file://package4/windows/system32/sqlpal.dll+0x000000000026CD97
                 file://package4/windows/system32/sqlpal.dll+0x000000000026C7E7
                 file://package4/windows/system32/sqlpal.dll+0x0000000000236C9C
                 file://package4/windows/system32/sqlpal.dll+0x0000000000236B97
                 file://package4/windows/system32/sqlpal.dll+0x0000000000251A0C
                 file://package4/windows/system32/sqlpal.dll+0x000000000024F96C
                 file://package4/windows/system32/sqlpal.dll+0x0000000000203243
                 file://package4/windows/system32/sqlpal.dll+0x000000000037CC08
                 file:///Windows/SYSTEM32/KERNELBASE.dll+0x000000000006F94F
                 file:///binn/sqlmin.dll+0x00000000001AD508
                 file:///binn/sqlmin.dll+0x00000000001AD7E7
                 file:///binn/sqlservr.exe+0x0000000000003C0B
                 file:///binn/sqldk.dll+0x00000000000A3A40
                 file:///binn/sqldk.dll+0x000000000007BE9A
                 file:///binn/sqldk.dll+0x0000000000018E52
                 file:///binn/sqldk.dll+0x00000000000144B2
                 file:///binn/sqldk.dll+0x0000000000013D82
                 file:///binn/sqldk.dll+0x00000000001121C9
                 file:///binn/sqldk.dll+0x0000000000009B33
                 file:///binn/sqldk.dll+0x000000000000A48D
                 file:///binn/sqldk.dll+0x000000000000A295
                 file:///binn/sqldk.dll+0x0000000000027020
                 file:///binn/sqldk.dll+0x0000000000027B2B
                 file:///binn/sqldk.dll+0x0000000000027931
                 file:///Windows/SYSTEM32/KERNEL32.DLL+0x0000000000013424
                 file:///windows/system32/ntdll.dll+0x0000000000073411<unknown>+0x0000000073030C00
        Process: 61 - sqlservr
         Thread: 186 (application thread 0x18c)
    Instance Id: 533c5e1e-8baf-45a0-9c8f-01c6503a48c0
       Crash Id: e64632db-4b68-4243-b0f0-d29accb848e6
    Build stamp: 9d61bcf28d2533f40f3df073a5c55d3c36750b6b1e650db137f069439b440661
   Distribution: Ubuntu 18.04.4 LTS
     Processors: 4
   Total Memory: 16797073408 bytes
      Timestamp: Tue May 12 17:16:29 2020

This error was the result of this SQL statement:

RESTORE DATABASE [2a316a2b-cc2a-4df6-894a-751ee9f5b486]
                          FROM DISK = '/mnt/scratch/2a316a2b-cc2a-4df6-894a-751ee9f5b486.ifi'
                          WITH REPLACE, MOVE 'data' TO '/mnt/scratch/2a316a2b-cc2a-4df6-894a-751ee9f5b486.mdf',
                          MOVE 'log' TO '/mnt/scratch/2a316a2b-cc2a-4df6-894a-751ee9f5b486_log.ldf';

The database in this situation is around 10GB.

The docker image we are using is mcr.microsoft.com/mssql/server:2019-latest

Would greatly appreciate any assistance. 

Group by and row_number

$
0
0

Suppose I am having a table

col1      col2     col3

a          a1         testing_a1_1

a          a1         testing_a1_2

a          a2         testing_a2_1

a          a2         testing_a2_2

How can I make a query to have

colnew  col1      col2                  col3

 1              a          a1         testing_a1_1

1               a          a1         testing_a1_2

2               a          a2         testing_a2_1

 2               a          a2         testing_a2_2

is it possible to use row_number() over to do it ?

Reusable assets on MS SQL Server for DBA

$
0
0

Hi

Can you please share few examples for creating reusable assets on MS SQL Server for DBA.

Reusable assets: - tasks that are common and repeated - maximize productivity through asset reuse.

Thanks in advance.

Attach database with only MDF file

$
0
0

Dear All,

SQL server version is 2008 R2 Standard Edition . Only a particular mdf exists for a database , there is no ldf file for the database . Can we attach the database without ldf.

Appreciate your kind cooperation .

Best Regards,
Sandy

Turning Off TDE takes time

$
0
0

Hello All,

I have TDE enabled DB which is required to be restore in other regions where TDE is key not required. But here turning off the TDE takes more than 8 hrs. So is there anyway we speed the process? I have already tried shrinking the logs, dropped un wanted tables

Viewing all 15264 articles
Browse latest View live


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