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

SQL Server Password Expire

$
0
0

Hi,

One of db user saying he is not able to login to database. After checking I found the user account is disabled. Password policy & password expiration is enabled for the user. I am not sure whether the account was manually disabled or not. Can anyone tell me if SQL Server user password is expired then the account becomes disabled automatically?



SQL Profiler Trace Skipped Records

$
0
0

 

What causes SQL Profiler to show "SQL Profiler Trace Skipped Records"?

SQL2005 SP2 64bit

 

Thanks.

Identity Columns Randomly Regress to a Lower Value

$
0
0

Hello,

We have an in-house developed database application that uses SQL Server 2016 (13.0.5101.9) for backend data storage. Numerous tables have identity columns configured as the key field. This week two of these identity columns randomly changed to substantially lower numbers. 

In one case the identity column changed from 20200954 to 20160296. In the other case the identity column changed from 20200000 to 20120046. In both cases the identity column was configured as an INT value with an increment step of 1. 

We had previously encountered the better known issue where identity values can skip by 1000 during a server restart. We took the prescribed measures to eliminate this.

Anyhow, in approximately ten years of use of this application (using two or three versions of SQL Server over this time), I don’t ever recall experiencing identity values randomly regressing to a lower value. I am wondering…

1.)   If anyone else has experienced this?

2.)   Is this a known issue?

3.)   Is there a known remedy?

It’s very unsettling having identity values randomly change.

Thank You,

Dale

Saying incorrect syntax for a userdefined function

$
0
0

Hi,

I am using the AdventureWorks2017 database and learning how to write functions at the moment but the basic function I have written is coming back with an incorrect syntax error.

The function I have written is just to pull the order ID from a table using the order ID. It is simple I know, but its just so I can learn the concept before moving to more advanced function scripting.

This is my code:

create function ufnGetOrderID(@OrderID int) returns int
as

begin

	select 
		@OrderID = salesorderID 
	from 
		sales.SalesOrderDetail 
	where 
		SalesOrderID = @OrderID

return @OrderID

end


I am running the function as per the below:

exec dbo.ufnGetOrderID(43659)

But I am faced with the below errors:

I hover over the function name and get this-

"Procedure or function 'ufnGetOrderID' expects parameter '@OrderID', which was not supplied."


I hover over the 42659 in brackets and get this-

"Incorrect syntax near '43659', expecting '(', or SELECT."


What am I doing wrong?

Thanks,

Dan

Insert into OPENDATASOURCE with Microsoft.ACE.OLEDB.16.0 provider - failed (EXCEPTION_ACCESS_VIOLATION)

$
0
0

Hi all,

we export data into Excel file from SQL Server 2017 with a simple command (a part of a stored procedure): 

The command looks like:

INSERT INTO OPENDATASOURCE('Microsoft.ACE.OLEDB.16.0', 'Excel8.0;HDR=YES;IMEX=1;Database=\\some_folder\excel1.xls')...Sheet1
    SELECT * FROM table1

It works fine. But only if just one export is processing at the same time.

If more exports are processing simultaneously, the exports crashes, an exception is raised.

"SqlDumpExceptionHandler: Process 68 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process."

One process is terminated, the other ones are hanging and no other export is possible to start, unless restarting the sql server service.

We are not sure, is it a problem of OLEDB driver or of SQL server service?

Thank you for any advice, 

jirpun

 

 

What if you remove cluster role on the last node of the windows 2016 cluster with SQL always on group exists

$
0
0

this question might be crazy in production, but it happened in my test, I create a cluster and created SQL always on group on it. later I uninstalled the cluster service, 

it happened: the AlwaysOn group databases show as restoring. the AG is not responsible, if try to drop the AG, get

Msg 41081, Level 16, State 0, Line 6
Failed to destroy the Windows Server Failover Clustering group corresponding to availability group 'AG1'.  The operation encountered SQL Server error 41000 and has been terminated.  Refer to the SQL Server error log for details about this SQL Server error and corrective actions.
Msg 41108, Level 16, State 0, Line 6
An error occurred while removing availability group 'AG1'. The DROP AVAILABILITY GROUP command removed the availability group configuration from the local metadata. However, the attempt to remove this configuration from the Windows Server Failover Clustering (WSFC) cluster failed because the Always On Availability Groups manager is not online (SQL Server error: 41081). To remove the availability group configuration from the WSFC cluster, re-enter the command.

then I added the cluster role back,  sure the cluster service is not started unless the cluster with original name exists. 

then I clear the box so as not to enable alwayson high availability group, now the sql server is back to a standalone server. 

the only mess is to clear the AD entries for the original cluster name and the AG group listener name, I believe nothing else? please advise.

Also, just wondering the logic, why it is allowed to remove cluster role on the primary node of a cluster where AG resources exists.

Backup error logging

$
0
0

Hi All,

Need some help in exception handling. In below code, I want to know the reason why the backup is failing.

For testing purpose, I have intentionally given wrong path of the backup file. i.e. Z: drive doesn't exist and when I run the backup command alone, it gives exact error message saying path not found. However, if I run the code inside an exception block, I am not getting exact error message. How to capture the exact error message ?? If everything works fine, I want to log that error in a errorlogging table.

 BACKUP DATABASE testdb TO DISK = 'Z:\testdb\testdb_Full_20191018.BAK';

/*
Msg 3201, Level 16, State 1, Line 4
Cannot open backup device 'Z:\testdb\testdb_Full_20191018.BAK';. Operating system error 3(The system cannot find the path specified.).
Msg 3013, Level 16, State 1, Line 4
BACKUP DATABASE is terminating abnormally.
*/

Running with try - catch block

BEGIN TRY
        BACKUP DATABASE testdb TO DISK = 'Z:\testdb\testdb_Full_20191018.BAK';
 END TRY
 BEGIN CATCH  
       SELECT  
            ERROR_LINE() AS [Error_Line],
            ERROR_MESSAGE() AS [Error_Message],
            ERROR_NUMBER() AS [Error_Number],
            ERROR_SEVERITY() AS [Error_Severity],
            ERROR_PROCEDURE() AS [Error_Procedure];

END CATCH

Thanks,

Sam

How to get values from a 2nd result set

$
0
0

All, I have a query that returns 2 result sets as shown in the screen shot.  My problem is I want to get the value in the first column of the 2nd result set, but I'm afraid I don't know how to do that.  Any help would be appreciated:


Tim

DECLARE @maj int=7,
@min int=4,
@maint int=0,
@b int=300,
@r char(1)

SELECT top 1 major,minor,Maintenance,build
FROM Maintenance.DatabaseVersion
WHERE EXISTS
    (SELECT top 1 Major,Minor,Maintenance,Build 
     FROM Maintenance.DatabaseVersion
     WHERE major = @maj
	 AND minor = @min
	 AND Maintenance = @maint
	 AND Build = @b
     ORDER BY DatabaseVersionID DESC
	 );
	If @@ROWCOUNT = 0 
		begin
			set @r = 'N'
		End
		else
		begin
			set @r = 'Y'
		end
SELECT @r as UPD



SQL Server 2017 - CU17 patch installation on DAG

$
0
0

Hi All,

Please review below steps to install SQL 2017 - CU17 patch on Distributed Always-ON (DAG) environment. Please correct me if I have missed any steps.

DB1 and DB2 servers are hosted on DC1

DB1 and DB2 servers are hosted on DC2

DC1-DB1 is the primary (Production) server.

Step 1: Install patch on DC2-DB1 and reboot server

Step 2: Install patch on DC2-DB2 and reboot server

Step 3: Install patch on DC1-DB2 and reboot server

Step 4: Install patch on DC1-DB1 and reboot server

Step 5: Failover from DC1-DB2 to DC1-DB1. Ensure DC1-DB1 is primary (Production)

DC1 - DAG:

DC2 - DAG:



client connectivity error.

$
0
0

hi all

We run ETL jobs daily through Informatica Powercenter and we are getting following error randomly on this server while connecting to SQL Server. When we re-run the job it runs fine. This is suddenly started happening within last 1 month. There were few security windows patches applied on the informatica server, but none of them were related to SQL server, they are all windows hotfixes/updates etc.

Any pointers will be appreciated.

Microsoft SQL Server Native Client 11.0 : Login timeout expired
SQL State : HYT00 Native Error: 0

Microsoft SQL Server Native Client 11.0 : Unable to complete login process due to delay in prelogin response
SQL State : 08001 Native Error: 258

Microsoft SQL Server Native Client 11.0 : TCP Provider: Timeout error [258]
SQL State : 08001 Native Error: 258
State: 1 Severity: 16
SQL Server MEssage: TCP Provider: Timeout error [258]

what would be affected if I change database master key password? will the application affected?

Issue with job running sometimes very long struck and other time in 10 min

$
0
0

I am facing issue with one of the job running sometimes too long 10hrs I have to kill it.

This is happening at two places in code which has merge and insert in SP and when I kill and restart it finishes quickly 

I have identified the code and looking into what is happening in b/g using profiler 

In profiler I have located the spid and other details, now exactly want to know what is happening

Help me from where to start in profiler 


Neil



Migration failing due to index

$
0
0

Hi 

The development team recently added a migration to add new columns and remove deprecated older columns on a table:

This migration removes DTStyleLoc and DTStyleStgLoc_Id columns from the Dpts table.

The migration failed when tested on QA with prod data which means it would probably fail in production.

It failed because there was an existing index (IDX_Dpts_CId_IsDeleted) that used these deleted columns. This index name is also slightly different on other databases in production environment. 

Any advice on how we I should tell them to proceed with something like this? Update the indexes somehow? Remove the indexes? Don't remove the columns at all in the first place?

Basic questions about snapshots

$
0
0

I thought I understood snapshots, I guess not.  I have rarely used them.  So one scenario where I'm considering them is for use in reporting.  I know full well the impact of running a complex report that his the same transactional Db that users are on.  However, its how a snapshot works that Im not clear on, esp regarding the changes that happen in the primary Db.

https://www.mssqltips.com/sqlservertip/1010/sql-database-snapshots-for-reporting-auditing-and-data-recovery/

this part:
As data changes in your primary database, SQL Server then writes out what the data looked like prior to the data change into a sparse file, so this way the data stays static. The snapshot will then read the sparse file for the data that has been changed and continue to read the primary database for data that has not changed. Since the initial snapshot is reading from your primary database, the creation of a database snapshot is immediate.

Questions:

(1) If the snapshot is created at 10 pm and 20 new records get added in the primary Db, will I see those records when querying the snapshot?

(2) Say you have a scenario where your main Db is getting updated primarily during business hours (9-5 etc) and your full backups run from 12:00 to 1am.  When would be a good time to create a snapshot?  Before or after the backup?  Why not just create a snapshot weekly?

(3) Similar to (1), say you have your primary Db getting updated by users of several applications and other things, mainly during business hours (eg. 9-5).  If a manager runs a report that uses a snapshot of this Db which was created at 2am that day, or 3 days ago, will they see any of the new records added since the snapshot was created?

Sort operator in Execution Plan

$
0
0

I have following simple query.

SELECT STT.SWallet_ID
FROM dbo.TRANSACTION STT 
WHERE STT.Keyword='apmt'
ORDER BY STT.SWallet_ID

Because of order by clause, the execution plan shows sort operator. To remove the sort, I tried various indexes bout could not. According to BOL, sort should be removed by using index on column stt.SWallet_ID.


SQL Server 2017 continuously using 100% CPU of one processor and backups can't be restored.

$
0
0

This is my first post, so apologies if I'm missing any of the protocols.

We are running SQL Server 2017 with the latest patches applied (14.0.3238.1). We use memory optimized tables in our database. There appears to be a number of issues which we can't get to the bottom of.

1. On startup, the database in question takes 10 mins or so to be available. Shortly afterwards there is a stack dump 

2019-10-21 22:19:03.99 spid5s      Recovery is complete. This is an informational message only. No user action is required.
2019-10-21 22:19:10.92 spid25s     ***Stack Dump being sent to C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\LOG\SQLDump0080.txt
2019-10-21 22:19:10.92 spid25s     SqlDumpExceptionHandler: Process 25 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
2019-10-21 22:19:10.92 spid25s     * *******************************************************************************
2019-10-21 22:19:10.92 spid25s     *
2019-10-21 22:19:10.92 spid25s     * BEGIN STACK DUMP:
2019-10-21 22:19:10.92 spid25s     *   10/21/19 22:19:10 spid 25
2019-10-21 22:19:10.92 spid25s     *
2019-10-21 22:19:10.92 spid25s     *
2019-10-21 22:19:10.92 spid25s     *   Exception Address = 00007FFB54A91860 Module(hkengine+0000000000191860)
2019-10-21 22:19:10.92 spid25s     *   Exception Code    = c0000005 EXCEPTION_ACCESS_VIOLATION
2019-10-21 22:19:10.92 spid25s     *   Access Violation occurred reading address 0000000000000030

2. After this, the database appears to function normally - but the server uses 100% of one CPU continuously. When we check for long running queries, there doesn't appear to be any (we also checked using a trace).

3. If we backup the database, then try and restore it on a different Windows server with a similar error, but it never recovers, with an error 'The database 'dotnetnuke' is marked RESTORING and is in a state that does not allow recovery to be run.'

4. Running: 

SELECT log_bytes_since_last_close /(1024*1024) as Log_bytes_since_last_close_mb,
time_since_last_close_in_ms,
current_checkpoint_id, outstanding_checkpoint_count, recovery_checkpoint_id, recovery_checkpoint_ts, closing_checkpoint_id, *
FROM sys.dm_db_xtp_checkpoint_stats
GO

as suggested on some forums gives:

Log_bytes_since_last_close_mb: 9655
time_since_last_close_in_ms: 24760718
current_checkpoint_id: 91
outstanding_checkpoint_count: 4
recovery_checkpoint_id: 87
recovery_checkpoint_ts: 247888
closing_checkpoint_id: 88

Running:

SELECT name, log_reuse_wait_desc
FROM sys.databases
GO

shows that log reuse is waiting for XTP_CHECKPOINT. However, when we run CHECKPOINT manually the logs say that the checkpoint is complete - the command in SQL Server management studio doesn't exit though and stays in 'Executing'

In summary, we are running constantly high CPU and can't restore the database backups to a different server. Any thoughts would be much appreciated.

BTW: Our server has 4 virtual CPUs and 16Mb RAM, and 20Gb of disk space spare. The database is in Simple recovery mode and the transaction log is 1Gb, while the transaction log has bloated to 10Gb.

1.0.0.20

Sql Server 2019

$
0
0

Hi,

Could anyone please help to know that 2019 Sql Server Enterprise Edition, or any other version is available for production server? 

I did study and per my knowledge latest version Sql Server 2019 CTP 3.2 is available. However, CTP version is not for production server? This version is for users and software developer for testing? 

Any suggestions, please? Thank you very much!


Obtain database version from DACPAC file

$
0
0

Hello, I would like to know if it is possible to somehow extract the database version from the DACPAC itself?  If it is, I don't know how to do it.

Appreciate any and all advice!


Tim

Restore is failing

$
0
0

Hi All,

Unable to restore/refresh a database. I was able to kill the sessions but still I was unable to restore.

When I try to use below query, I get below output. A negative spid on that database.

select

    db_name(l.resource_database_id) as dbname,
    l.resource_type,
    l.request_mode,
    l.request_status,
    l.request_session_id,
    r.command,
    r.status,
    r.blocking_session_id,
    r.wait_type,
    r.wait_time,
    r.wait_resource,
    request_sql_text = st.text,
    s.program_name,
    s.host_name,
    s.login_name,
    s.status,
    s.nt_domain,
    most_recent_sql_text = stc.text
from sys.dm_tran_locks l
left join sys.dm_exec_requests r
on l.request_session_id = r.session_id
left join sys.dm_exec_sessions s
on l.request_session_id = s.session_id
left join sys.dm_exec_connections c
on s.session_id = c.session_id
outer apply sys.dm_exec_sql_text(r.sql_handle) st
outer apply sys.dm_exec_sql_text(c.most_recent_sql_handle) stc
where l.resource_database_id = db_id('mydb')
order by request_session_id;
--https://dba.stackexchange.com/questions/57432/database-is-in-transition-error

What can be done ? Please help.

Cant take the database to single user mode as well. It is keep on running and eventually had to cancel single_user statement as well …. And I am seeing below output.

Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
Query was cancelled by user.

 

Checked for negative spids and wasnt able to KILL it.

uSE Master;
GO

SELECT
DISTINCT(request_owner_guid) as UoW_Guid
FROM sys.dm_tran_locks
WHERE request_session_id =-2
GO

guid

KILL '00000000-0000-0000-0000-000000000000'

Msg 6110, Level 16, State 1, Line 5
The distributed transaction with UOW {00000000-0000-0000-0000-000000000000} does not exist.

Will restarting MSDTC service in services.msc will fix the issue? This is a dev server by the way.


Thanks,
Sam


Warning of No statistics on a column

$
0
0
For a query execution plan is showing warning of no statistics on a column but the statistics for that column exists.
Viewing all 15694 articles
Browse latest View live


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