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

Graph Tables in SQL Server 2017

$
0
0

I downloaded trial version of MS SQL Server 2017 and setup in my VM to understand about graph tables. I followed articles from:

https://docs.microsoft.com/en-us/sql/relational-databases/graphs/sql-graph-sample?view=sql-server-2017
https://www.mssqltips.com/sqlservertip/4883/sql-server-2017-graph-database-example/

to understand graph capabilities. For a given Node table, I tried to load more records which crossed more than 1000 records and I am getting below error:

Msg 10738, Level 15, State 1, Line 1002
The number of row value expressions in the INSERT statement exceeds the maximum allowed number of 1000 row values.

Any reason why this limit? Please share what can be corrected.

Thank you



SQL server Database performance issue

$
0
0

Hi,

we are using solarwind monitor tool and our database size is around 500 Gb and we have checked index fragmentation detail most of the index size is 99 %. we are planning to do rebuild and update status activity. we are not able to stop the application. Kindly suggest how much time will take for complete the rebuild activity. Is there any issue will occur  during this activity. 

Regrads,

karthik 

Database transaction log is full due to 'CHECKPOINT'

$
0
0

Hi Folks,

I found error Database STG_XYZZ transaction log is full due to 'CHECKPOINT' in error logs. On checking log_reuse_wait_desc column, I found that log_reuse_wait_desc value is = NOTHING for the database STG_XYZZ

I found that Recovery model of STG_XYZZ database is in simple. 

I also found that the value for tempdb it is 'ACTIVE_TRANSACTION'

I wants to know how to tune or resolve this issue of CHECKPOINT & ACTIVE_TRANSACTION

SQL Server : 

Microsoft SQL Server 2012 (SP3) (KB3072779) - 11.0.6020.0 (X64) 
Oct 20 2015 15:36:27 
Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)

Windows Version : Windows Server 2008R2 Enterprise 64-Bit

SQL connection error from remote

$
0
0

Hello All:

I've a C# application which connects with SQL Database to perform read and write. I'm able to connect to SQL server when I run the application locally where SQL server resides. I created a run time version of the C# application and tried to run from the other machines. It is not connecting to the SQL server. It is giving the error as shown below.

SQL server is configured to accept remote connection. I also added inbound rules for TCP UDP ports and SQL webserver in the firewall configuration. But the problem still exists. Could anyone please help me with this?

Thanks,

Shwetha.

Weird Double Hop Issue

$
0
0

Hi there

We're gradually migrating all databases between SQL Server 2014 to SQL Server 2016

We've always catered for the double hop scenario fine by resgistering the SPN's and delegating access for Kerberos.

The issue we've come across is that with the two SQL Servers, by adding in Linked Servers then the connection works fine between Instances of SQL 2014 to other instances of SQL 2014 (as these are already in existance).  Linked Servers works fine between Instances of the new SQL 2016 and other instances of SQL 2016.

Similarly, Linked Servers ok between Instances of SQL 2014 and Instances of SQL 2016

However, if I create the Linked Servers on the SQL 2016 itself, then all fine, all catalogs displayed etc, but when users try to work on their local machine using SSMS for example, they cannot see any of the catalogs (databases) under that linked server.  So if they connect to an SQL 2014 instance, they can see 2016, but not vice versa.

I've checked the SPNs are all set up ok, and have checked that Trust this computer for delegation to any service is selected under the Delegation tab for the new 2016 server.

The only thing is slightly different is that for the 2014 server, I'm using the ordinary Managed Service Accounts, whereas on the 2016 server I'm using the newer group managed service accounts.

Sure I must be missing something straightforward as I cannot see any difference in setup for these Linked Servers between the two versions.

Any help most appreciated.

Cheers

Ian

How to measure the SQL Server MTL Memory

$
0
0

Having issues with the following scenario, pls help if anyone can Measure the MTL Usage.

DB Environment Details

Windows/SQL Server
2008 R2 with 64 Bit
SQL Max Memory 12 GB ( BPool Area )
3 GB for MTL (
Non-Bpool )
Max Worker Thread 512

Application Environment Details
Solaris Server with 64 Bit 32 GB RAM
4 Instance
Application with 20 SQL Connection each
Application use the ODBC Drivers for
connecting SQL Database

• Application getting restarting when allowing with default memory setting due to insufficient memory
• Application working fine when default MTL setting changed to 3GB using –g switch during SQL Server Startup.

In the test lab server, we did not have any issues after allocating  the Custom Memory while startup using –g ( 3GB Size )

By using below Query, MTL not crossing more than 100 MB

select type, sum(single_pages_kb) BPool, sum(multi_pages_kb) MTL from sys.dm_os_memory_clerks
where multi_pages_kb > 0 group by type order by 3 desc

Questions:
• Why the application restarting at the time of default Memory setting, I hope by default It suppose to have atleast 1 GB and my application not even consuming ¼ of the 1 GB but still application restarting.

• Similarly, why the application not restarting when memory increased for the MTL Portion to the higher value.

• Which query will help me for measuring the MTL Usage for the allocated 3 GB. Output like,

Allocated MTL Area : 3 GB
Consumed
MTL : 250 MB
Free MTL Space : 2822 MB

Because, based on the SQL Script I will scale up the Memory usage by the C/C++ Applications.
 
For easy understanding I have attached the App and DB Layer.

Please share your thoughts for measuring the memory usage.


Moving SCCM And Report Server Databases

$
0
0

Hello forum

We are using SCCM version 1807, that is using SQL Server 2014 Databases for it's primary data store and for Reporting Databases (Reporting Services).  We need to move these Databases to another 2014 Instance as it has been installed on the wrong Server.

We have been reviewing the following article and we have a couple of concerns

https://blogs.technet.microsoft.com/configurationmgr/2013/04/02/how-to-move-the-configmgr-2012-site-database-to-a-new-sql-server/

The article (under step 3) states that the default collations should match, however on the source Server we have SQL_Latin1_General_CP1_CI_AS and on the destination Server we have SQL_Latin1_General_CI_AS; do the collations matter?  If so as a part of the restoration process, can we alter the collation on the restored database to match that of the default collation, has anyone tried this before?

Nowhere in the Article is the migration of the Reporting Services Databases mentioned, or how to alter to configuration to suit, does anyone know how to do this?

Many Thanks


Please click "Mark As Answer" if my post helped. Tony C.




Linked server to MySQL Problem

$
0
0

Hi guys,

I've a linked server through OleDB to MySQL database , I use it for getting data and write into mysql single table, it works fine but when there are many query transaction it occurs a lot of errors.

My question is: there is another method for improving get data from MySQL?

thanks

bye


restore database without With replace

$
0
0

I always think that you need put with replace clause to restore overwrite an existing database, however, I just happened to restore a database overwriting an existing one without WITH REPLACE, not sure if this is supposed to be.

restore database MAP201808 from disk='e:\map.bak' with 
move 'map' to '...map201808.mdf',
move 'map_log' to '...map201808.ldf';
dbcc checkdb('map201808') with no_infomsgs;

deadlock issue.

$
0
0

hi all,

Im getting following information from idera tool for one of the deadlock issue.

Session 63: (this is Victim)

has key lock on object : mode X (OWN)

it is also waiting on lock on same object but mode is U (I guess U is update lock)

In the details section of session 63 , i see update is being run as follows:

UPDATE TAY_DoorTrailer
   SET num_trailer_door = (SELECT COUNT(1) FROM TAY_DoorTrailer WITH(NOLOCK) WHERE door_id = @pDoorID)
   WHERE door_id = @pDoorID     

--

Session 69

has a key lock on the same object , however row is different (cause the binary value as shown in parenthesis of KEY:xx:xx(xxx) is different. 

it is owning X lock on this object and waiting for U lock.

Following statement is being run.

UPDATE TAY_DoorTrailer
   SET num_trailer_door = (SELECT COUNT(1) FROM TAY_DoorTrailer WITH(NOLOCK) WHERE door_id = @pDoorID)
   WHERE door_id = @pDoorID     

--

In my opinion, same update statement is being run by both the sessions, however different rows are trying to get updated im not sure about what value is being passed to these parameters, but to resolve occurrences of deadlock , will creating any index help? Also is my understanding correct about why deadlock is happening?

There is already individual index on num_trailer_door and door_id fields, these are two different indexes.

How to fix Error 1483 Severity 10 'Commit LSN: '(37:219224:2)' Commit Time: 'Jun 17 2018 3:27AM' 'keeps occuring very often in few production servers

$
0
0

Error: Commit LSN: '(37:219224:2)'    Commit Time: 'Jun 17 2018  3:27AM'&#x0D;
</TextData>

Can anybody help me to fix this error which keeps on occurring on production servers very often? Or explain the reason behind it's occurrence?

Installing SQL Server 2017 Machine Learning Services hangs on the last screen, before Complete

$
0
0

You are left wondering what to do next. Cancel  or wait?

if wait, how long?


Jayaram Krishnaswamy

BULK INSERT and Skip a Column

$
0
0

Hi,

I want to use BULK INSERT to import data from data file. But skip a field. I refer to the document at https://docs.microsoft.com/en-us/sql/relational-databases/import-export/use-a-format-file-to-skip-a-table-column-sql-server?view=sql-server-2017 . However, my case is that the data for field 2 exists in the data file, but I DO NOT want map it to column2, so I modify the XML file as below(different from the sample in the document):

<?xml version="1.0"?> 

<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 

 <RECORD> 

  <FIELD ID="1" xsi:type="CharTerm" TERMINATOR="," MAX_LENGTH="7"/>

  <FIELD ID="2" xsi:type="CharTerm" TERMINATOR="," MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>

  <FIELD ID="3" xsi:type="CharTerm" TERMINATOR="\r\n" MAX_LENGTH="100" COLLATION="SQL_Latin1_General_CP1_CI_AS"/> 

 </RECORD> 

 <ROW> 

  <COLUMN SOURCE="1" NAME="Col1" xsi:type="SQLSMALLINT"/> 

  <COLUMN SOURCE="3" NAME="Col3" xsi:type="SQLNVARCHAR"/> 

 </ROW> 

</BCPFORMAT>

Note I use SOURCE="3" to indicate ‘Col3’ will use the data from field with ID=”3”. However, when I try to import data with the format file, I find the resultant table is corrupt, the data are shifted. Why?

What is this wait_resource?

$
0
0

Greetings. I have a service broker process that does integrity checks on several tables at once, as opposed to one at a time like a normal maintenance plan.

I was just trying to diagnose where any bottlenecks may lie, and notice a lot of the following:

wait_type, wait_resource

LCK_M_X , FILE: 10:0

I know 10 is my database ID, but what is the 0? Typically this value is the file ID, but there is no file ID 0. I've been googling this for a while to no avail.


Thanks in advance! ChrisRDBA

SQL Service failing to start with TCP IPV6 1433 port already in use error

$
0
0
Hi All, 

Need your advise on TCP Port in use error. 



We have a DB Server where we could see connections coming from application. But seems there are not outgoing connections to application server. 

On trying to restart SQL Service, we are facing below errors and had to keep restarting windows server each time.

"Server TCP Provider failed to listen on [any <ipv6> 1433. TCP Port already in use"

and

"TDCNIClient initializtion failed with error 0x2740, status code 0xa. Reason unable to initialize TCP/IP Listener. Only one usage of each socket address(protocol/network address/port) is normally permitted. 

On verifying netstat -a there are no connections via 1433 port when SQL Service is stopped. Please help to advise on possible cases of investigation in this case. 

Capture the required stored stored procedures to execute

$
0
0

Dear All,


I'm trying to create a query which will recompile stored procedures which take longto execute and here is the query I 'm using, I need to know how to capture the actual stored procedures as at the moment I can only get the database which they are coming from:


SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

SELECT TOP 100
qs.execution_count AS [Runs]
, (qs.total_worker_time - qs.last_worker_time) /
(qs.execution_count - 1) AS [Avg time]
, qs.last_worker_time AS [Last time]
, (qs.last_worker_time - ((qs.total_worker_time - qs.last_worker_time)
/ (qs.execution_count - 1))) AS [Time Deviation]
, CASE WHEN qs.last_worker_time = 0
THEN 100
ELSE (qs.last_worker_time - ((qs.total_worker_time -
qs.last_worker_time) / (qs.execution_count - 1))) * 100
END
/ (((qs.total_worker_time - qs.last_worker_time)
/ (qs.execution_count - 1))) AS [% Time Deviation]
, qs.last_logical_reads + qs.last_logical_writes
+ qs.last_physical_reads AS [Last IO]
, ((qs.total_logical_reads + qs.total_logical_writes +
qs.total_physical_reads) - (qs.last_logical_reads +
qs.last_logical_writes + qs.last_physical_reads))
/ (qs.execution_count - 1) AS [Avg IO]
, SUBSTRING (qt.text,(qs.statement_start_offset/2) + 1,
((CASE WHEN qs.statement_end_offset = -1
THEN LEN(CONVERT(NVARCHAR(MAX), qt.text)) * 2
ELSE qs.statement_end_offset
END - qs.statement_start_offset)/2) + 1) AS [Individual Query]
, qt.text AS [Parent Query]
, DB_NAME(qt.dbid) AS [DatabaseName]
INTO #SlowRunningQueries
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.plan_handle) qt
WHERE qs.execution_count > 1
AND qs.total_worker_time != qs.last_worker_time
ORDER BY [% Time Deviation] DESC



SELECT TOP 100 [Runs]
, [Avg time]
, [Last time]
, [Time Deviation]
, [% Time Deviation]
, [Last IO]
, [Avg IO]
, [Last IO] - [Avg IO] AS [IO Deviation]
, CASE WHEN [Avg IO] = 0
THEN 0
ELSE ([Last IO]- [Avg IO]) * 100 / [Avg IO]
END AS [% IO Deviation]
, [Individual Query]
, [Parent Query]
, [DatabaseName]
INTO  #SlowRunningQueriesByIO
FROM #SlowRunningQueries
ORDER BY [% Time Deviation] DESC



SELECT TOP 100
[Runs]
, [Avg time]
, [Last time]
, [Time Deviation]
, [% Time Deviation]
, [Last IO]
, [Avg IO]
, [IO Deviation]
, [% IO Deviation]
, [Impedance] = [% Time Deviation] - [% IO Deviation]
, [Individual Query]
, [Parent Query]
, [DatabaseName]
INTO #QueriesRunningSlowerThanNormal
FROM #SlowQueriesByIO
WHERE [% Time Deviation] - [% IO Deviation] > 20
ORDER BY [Impedance] DESC



SELECT DISTINCT
' EXEC sp_recompile' + ''+ '[' + [DatabaseName] + ']'  AS recompileRoutineSQL
INTO #RecompileQuery
FROM #QueriesRunningSlowerThanNormal 
WHERE [DatabaseName] NOT IN ('master', 'msdb', 'model','tempdb', 'distribution')


DECLARE @RecompilationSQL NVARCHAR(MAX)
SET @RecompilationSQL = ''

SELECT @RecompilationSQL = @RecompilationSQL
+ recompileRoutineSQL + CHAR(10)
FROM #RecompileQuery
WHERE recompileRoutineSQL IS NOT NULL

DECLARE @StartOffset INT
DECLARE @Length INT
SET @StartOffset = 0
SET @Length = 4000

WHILE (@StartOffset < LEN(@RecompilationSQL))
BEGIN
PRINT SUBSTRING(@RecompilationSQL, @StartOffset, @Length)
SET @StartOffset = @StartOffset + @Length
END

PRINT SUBSTRING(@RecompilationSQL, @StartOffset, @Length)

EXECUTE sp_executesql @RecompilationSQL

DROP TABLE #SlowRunningQueries
DROP TABLE #SlowRunningQueriesByIO
DROP TABLE #QueriesRunningSlowerThanNormal
DROP TABLE #RecompileQuery

Thank you in advance

Auto-Disable logins after defined time

$
0
0

Routine administration task is to enable logins for a defined time. So let's say I am asked to create/enable login and then automatically disable after 1 year or 6 months. I did not see anything native built. I could only create a table containing logins with the specified disabling date and have a SQL agent job that checks and disables.

Please let me know if any other idea.

Thank you,

SQL Server 2016 Stored Procedure Syntax Error

$
0
0

I recently restored a SQL Server 2008 database into an instance of SQL Server 2016. Most of the functionality seems to work fine, but many of my stored procedures that include updates to an application database table called SYS_USER fails with the following error: "Msg 102, Level 15, State 1, Procedure SYS_USERupdate, Line 35 [Batch Start Line 0] Incorrect Syntax near '@errorNumber'".

The database does not have a stored procedure called SYS_Userupdate and none of the procedures' code includes the term '@errorNumber'. I attempted to run the SQL query from one of the failing procedures directly in SQL Server Management Studio and received the same error message. Here is the SQL query that is failing:

UPDATE SYS_USERSET SYS_USER_LGF_DT= GETDATE()WHERE SYS_USER_ID=@SYS_USER_ID

I plugged in a valid value for the @SYS_USER_ID variable. Similar queries in related to other tables run without an issue. All of the stored procedures work on a SQL Server 2008 instance with no errors. Also, the database compatibility_level to 100, which should be acceptable for SQL Server 2016. Any help would be greatly appreciated!

"Procedure Cache Hit Ratio" is low ?

$
0
0

I have given enough memory to server ,so memory is definitely not the case ,and i am using sql server 2016 in which while monitoring through a tool DPA ,i got to know about my procedure cache hit ratio is low (till 60%) ,please help 

Thanks in advance 

 

Consuming too much virtual memory

$
0
0

Hello,

 I have a SQL server with a minimal install (i.e. Management Tools, Database Engine).  I set the Max memory setting for 10GB.  The OS (Windows Server 2012R2) has 15GB physical memory installed and a max of 24 GB for Virtual memory.  My users are getting messages that the server is busy though to process requests.  I look at Task Manager Details pane and the SQLserver process is using almost all the virtual memory on the box.  Additionally it seems that no matter what I set the database Max memory to, the database still seems to use the same amount every time.  How can I prevent the database from consuming so much memory?

Viewing all 15264 articles
Browse latest View live


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