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

Intent locks

$
0
0

what's the differences between the following locks ?

Intent Shared (IS)

Intent Update (IU)

Intent Exclusive (IX)

Shared Intent Update (SIU)

Shared Intent Exclusive (SIX)

Update Intent Exclusive (UIX)


reuild index under bulk-logged recovery mode

$
0
0

If we set the database recovery option to bulk-logged before Rebuilding index, in-case during the rebuild index the system crash . 

the rebuild index operation will be ROLLBACK ?

Extent Allocation on the physical disk

$
0
0

is there any way to  make sure if the extent allocation (64KB) are continuously allocated (uniform extents) on the physical disk? 

Pre allocate the data files size can do that ?

SQL Server Agent Job Notifications Not Working

$
0
0
We have successfully setup Database Mail, and I am able to right click and 'Send Test E-Mail' and it works perfect. We have a few jobs setup in SQL Server Agent, and if the job fails it should e-mail us. Recently a job failed, but no e-mail. So I looked at the job log and see:

NOTE: Failed to notify 'Development' via email.

I confirm under Operators we have `Development` with the e-mail address I would like the error message to go to. Any ideas what would cause this?

dm_db_index_physical_stats

$
0
0

are there any calculation for column avg_fragmentation_in_percent ?

So avg_fragment_size_in_pages = Page_count/fragment_count.  

update statistics with sample

$
0
0

I am having a SQL Server 2016 instance , and I found that update statistics with sample 10 percent not always works for small tables. 

for example I have a table have 10000 rows , and update stats with sample 10 percent. Using dbcc show_statistics doesn't return sample 1000 rows. 

For bigger table (larger than 1M and more) , this seems work . 

Are there any threshold that SQL Engine will ignore the update stats with sample ?

After server restart, Tempdb not releasing space

$
0
0

Hello,

In my SQL instance I  have 1 TempDB mdf and 7 ndf files which all grew to 63 gb and filled up the 500 gb drive.

I got permission to reboot server, however, TempDB files did not shrink.

What should I do?

Query Xevent using TSQL

$
0
0

I have the following 2 xevent, and I am just wondering how to query it using TSQL ?

CREATE EVENT SESSION [audit_login] ON SERVER 
ADD EVENT sqlserver.error_reported(
    ACTION(sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_id,sqlserver.database_name,sqlserver.nt_username,sqlserver.session_id,sqlserver.session_nt_username,sqlserver.sql_text)
    WHERE ([package0].[equal_int64]([severity],(14)) AND [package0].[equal_int64]([error_number],(18456)) AND [package0].[greater_than_int64]([state],(1)) OR [package0].[equal_int64]([error_number],(18470)))),
ADD EVENT sqlserver.login(
    ACTION(sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_id,sqlserver.database_name,sqlserver.nt_username,sqlserver.session_id))
ADD TARGET package0.event_file(SET filename=N'H:\db_audit\audit_login.xel',max_rollover_files=(30))
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON)
GO




CREATE EVENT SESSION [audit_dba] ON SERVER 
ADD EVENT sqlserver.sql_statement_completed(SET collect_statement=(1)
    ACTION(sqlserver.client_app_name,sqlserver.client_hostname,sqlserver.database_id,sqlserver.database_name,sqlserver.nt_username,sqlserver.session_id,sqlserver.sql_text)
    WHERE ([sqlserver].[equal_i_sql_unicode_string]([sqlserver].[nt_user],N'user1') OR [sqlserver].[equal_i_sql_unicode_string]([sqlserver].[nt_user],N'user2')))
ADD TARGET package0.event_file(SET filename=N'H:\db_audit\audit_dba.xel',max_rollover_files=(30))
WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=ON)
GO


powershell Backup-SqlDatabase

$
0
0
Anyone know if there are verbose mode / or log output can output the results of Backup-SqlDatabase ?

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?



Intermittent Connectivity Issues

$
0
0

Application team is facing intermittent connectivity issues to the database, they are facing below error, after multiple tries they are able to connect to the database.

Databases servers are configured with 3 node AlwaysON.

Application Servers are on Azure. 

Could anyone help what could be the issue ?

Error:

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): Access is denied     


alter table to add columns doesnt seem to work

$
0
0

hi we are running 2014 enterprise and the following alter command doesnt seem to work...i tried rowversion also.  I know i've done something similar before but on later versions of sql most likely.

ALTER TABLE  mytable  ADD [RV] timestamp, RVcast bigint DEFAULT (CONVERT([bigint],[RV]))

i get the following error

Msg 128, Level 15, State 1, Line 1

The name "RV" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

Completion time: 2020-07-16T11:29:22.4958415-04:00

SQL Server Connection Issue

$
0
0

Microsoft SQL: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)

Getting above error intermittently with some prod DB servers (2016) while connecting from SSMS.

change datatype varchar to nvarchar in publication table (transaction Replication)

$
0
0

there is article published from serverA to serverB   (transaction Replication)

Table: product

datatype: varchar(50)

when am going to alter the table ,

alter table product alter column name nvarchar(50)

getting below error, & replication fails.

Msg 5074, Level 16, State 1, Line 32

The object 'v_fti_product' is dependent on column 'name'.

Msg 5074, Level 16, State 1, Line 32

The index 'is_product_site_id_vendor_id_includes__1' is dependent on column 'name'.

Msg 5074, Level 16, State 1, Line 32

The index 'IX_product_man__1' is dependent on column 'name'.

Msg 5074, Level 16, State 1, Line 32

The index 'IX_product_man___1' is dependent on column 'name'.

Msg 5074, Level 16, State 1, Line 32

The index 'NUNCLIX__56984' is dependent on column 'name'.

Msg 5074, Level 16, State 1, Line 32

The index 'ncls_Product_vendorid_incl_id_name' is dependent on column 'name'.

Msg 4922, Level 16, State 9, Line 32

ALTER TABLE ALTER COLUMN name failed because one or more objects access this column


SQLServerLogMgr::LogWriter: Operating system error 170(The requested resource is in use.)

$
0
0
Hello Experts,

        We have SQL Server 2012 on Windows server 2012 Failover cluster(VM).  Few days back we have installed Anti virus on Cluster nodes and got the error SQLServerLogMgr::LogWriter: Operating system error 170(The requested resource is in use.) Later we removed antivirus on both nodes. After couple of days again we started getting the same error and sql services are goes to stopped state. And if i perform failover then sql services are starting . Then after couple of hours later again it went to stopped state with the same error. This happened quite frequently in Node2 but on Node 1 it is happening very rarely.  Both nodes has different service packs and Windows CU.

Initially we thought it could be AV and now we completely removed still we are facing the same issue. 

Please help me to solve this nightmare issue.  



system error log

1:20:30 am

BackupIoRequest::ReportIoError: write failure on backup device 'G:\Backup\Dif_bkp\SCMDB_backup_2019_08_14_010128_7899718.bak'. Operating system error 170(The requested resource is in use.).

1:20:30 am

SQLServerLogMgr::LogWriter: Operating system error 170(The requested resource is in use.) encountered.

1:20:30 am 

The log for database 'msdb' is not available. Check the event log for related error messages. Resolve any errors and restart the database.

1:20:30 am 

The system failed to flush data to the transaction log. Corruption may occur in VolumeId: G:, DeviceName: \Device\HarddiskVolume5.
({Device Busy}
The device is currently busy.)

1:20:31 am 

The system failed to flush data to the transaction log. Corruption may occur in VolumeId: H:, DeviceName: \Device\HarddiskVolume3.
({Device Busy}
The device is currently busy.)

SQL Server Errorlog- 

Date,Source,Severity,Message
08/14/2019 07:21:10,spid6s,Unknown,SQL Server shutdown has been initiated
08/14/2019 07:21:10,spid6s,Unknown,Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup<c/> repair it<c/> or rebuild it. For more information about how to rebuild the master database<c/> see SQL Server Books Online.
08/14/2019 07:21:10,spid6s,Unknown,Operating system error 170(The requested resource is in use.) on file "H:\MSSQL11.MSSQLSERVER\MSSQL\DATA\mastlog.ldf" during FixupLogTail.
08/14/2019 07:21:10,spid6s,Unknown,Error: 5159<c/> Severity: 24<c/> State: 13.
08/14/2019 07:21:10,spid6s,Unknown,SQLServerLogMgr::FixupLogTail: Operating system error 170(The requested resource is in use.) encountered.
08/14/2019 07:21:10,spid6s,Unknown,Error: 17053<c/> Severity: 16<c/> State: 1.
08/14/2019 07:21:10,spid6s,Unknown,fcb status 0x42<c/> handle 0x00000000000007A8<c/> size 224 pages
08/14/2019 07:21:10,spid6s,Unknown,blankSize 0x3c0000<c/> blkOffset 0x11a<c/> fileSeqNo 884<c/> totBytesWritten 0x0
08/14/2019 07:21:10,spid6s,Unknown,SQLServerLogMgr::FixupLogTail (failure): alignBuf 0x000000001163E000<c/> writeSize 0xc00<c/> filePos 0x63400
08/14/2019 07:21:10,spid6s,Unknown,374 transactions rolled forward in database 'master' (1:0). This is an informational message only. No user action is required.
08/14/2019 07:21:10,spid6s,Unknown,Starting up database 'master'.
08/14/2019 07:21:10,Server,Unknown,Software Usage Metrics is disabled.
08/14/2019 07:21:10,Server,Unknown,CLR version v4.0.30319 loaded.
08/14/2019 07:21:10,Server,Unknown,Database Instant File Initialization: enabled. For security and performance considerations see the topic 'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required.
08/14/2019 07:21:10,Server,Unknown,Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
08/14/2019 07:21:10,Server,Unknown,Node configuration: node 0: CPU mask: 0x000000000000000f:0 Active CPU mask: 0x000000000000000f:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
08/14/2019 07:21:10,Server,Unknown,This instance of SQL Server last reported using a process ID of 11160 at 8/14/2019 7:21:08 AM (local) 8/14/2019 3:21:08 AM (UTC). This is an informational message only; no user action is required.
08/14/2019 07:21:09,Server,Unknown,Using conventional memory in the memory manager.
08/14/2019 07:21:09,Server,Unknown,Detected 49151 MB of RAM. This is an informational message; no user action is required.
08/14/2019 07:21:09,Server,Unknown,SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
08/14/2019 07:21:09,Server,Unknown,SQL Server detected 1 sockets with 4 cores per socket and 4 logical processors per socket<c/> 4 total logical processors; using 4 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
08/14/2019 07:21:09,Server,Unknown,Command Line Startup Parameters:<nl/>-s "MSSQLSERVER"
08/14/2019 07:21:09,Server,Unknown,Registry startup parameters: <nl/>-d H:\MSSQL11.MSSQLSERVER\MSSQL\DATA\master.mdf<nl/>-e H:\MSSQL11.MSSQLSERVER\MSSQL\Log\ERRORLOG<nl/>-l H:\MSSQL11.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
08/14/2019 07:21:09,Server,Unknown,The service account is 'account\sqlservice'. This is an informational message; no user action is required.
08/14/2019 07:21:09,Server,Unknown,Logging SQL Server messages in file 'H:\MSSQL11.MSSQLSERVER\MSSQL\Log\ERRORLOG'.
08/14/2019 07:21:09,Server,Unknown,Authentication mode is MIXED.
08/14/2019 07:21:09,Server,Unknown,System Manufacturer: 'VMware<c/> Inc.'<c/> System Model: 'VMware Virtual Platform'.
08/14/2019 07:21:09,Server,Unknown,Server process ID is 5280.
08/14/2019 07:21:09,Server,Unknown,All rights reserved.
08/14/2019 07:21:09,Server,Unknown,(c) Microsoft Corporation.
08/14/2019 07:21:09,Server,Unknown,Microsoft SQL Server 2012 (SP4) (KB4018073) - 11.0.7001.0 (X64) <nl/>Aug 15 2017 10:23:29 <nl/>Copyright (c) Microsoft Corporation<nl/>Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)



Thank you

Sai Nadh

How to get the information why SQL server and windows server went hung state?

$
0
0

Hello Experts,

 

SQL server is in windows cluster 2012 and it is in VM ware. Some times this server is going hung state and it is fail over to another node with out showing any error message. 

 

And there was no activity in background to at least to assume there is something. 

 

But last time i heard that it is because of Vmotion and holding sql server log files and trying to move to another vm node.  But this time there is no error message but sql went to stopped state. 

 

Is there any method to capture the information why sql server and windows server is going to hung state? 

 

 

 

This is the large error message i found it before it went to stopped state.

 

 

Cluster resource 'SQL Server' of type 'SQL Server' in clustered role 'SQL Server (MSSQLSERVER)' failed.

Based on the failure policies for the resource and role, the cluster service may try to bring the resource online on this node or move the group to another node of the cluster and then restart it. Check the resource and group state using Failover Cluster Manager or the Get-ClusterResource Windows PowerShell cmdlet.

PolyBase : Access Data in cosmodb using mongodb fails with error

$
0
0

Hi All,

I am trying to access data in my azure cosmosdb  using SQL Server PolyBase (cosmosdb was created using "Azure Cosmos DB for MongoDB API) 

I am able to connect and access documents using mongo shell. However when trying to create external table, getting below error.

Searched  though PolyBase logs and could not find any useful information which can help troubleshoot the issue.

Hence posting it here.

SQL Server version : Microsoft SQL Server 2019 (RTM-CU4) (KB4548597) 

CREATE DATABASE SCOPED CREDENTIAL azure_cosmos_db_cred_using_mongodb_connect_string

WITH IDENTITY = 'username', 
Secret = 'Key';

CREATE EXTERNAL DATA SOURCE AZ_CosmosDB_mongodb_connect
WITH ( 
LOCATION = 'mongodb://comsodb.mongo.cosmos.azure.com:10255', 
CREDENTIAL = azure_cosmos_db_cred_using_mongodb_connect_string ) 


CREATE EXTERNAL TABLE Cosmosdb_doc_mongodb_test (
[_id] NVARCHAR(24) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, 
[id] NVARCHAR(100) COLLATE SQL_Latin1_General_CP1_CI_AS 
)
WITH
(

LOCATION='sgcosdb.sgcosdbcnt', 
DATA_SOURCE = AZ_CosmosDB_mongodb_connect ) 


Msg 105083, Level 16, State 1, Line 13
105083;The following columns in the user defined schema are incompatible with the external table schema for table 'Cosmosdb_doc_mongodb_test': user defined column: 'id' was not found in the external table. The detected external table schema is: ([_id] NVARCHAR(24) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL).


SQLServer 2019 BDC comparision

$
0
0

All,

I have to come up with a comparison for SQLServer 2019 BDC. What other softwares can it be compared with (both Vendor based and OpenSource)?

Thanks,

gopi

getting error related to quoted identifiers on computed columns

$
0
0

hi we run 2014 standard.  does anybody know what this error means? its definitely related to a computed column i just added over which a non clustered unique index was built.  the computed column is called RVcast which is simply a cast of another recently added rowversion column into bigint.

---> System.Data.SqlClient.SqlException: INSERT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.


SQL Server 2016 SP2 > Database mail not sending mails.

$
0
0

Hi All.

I have several sql server instances running SQL Server 2016, sp2

Microsoft SQL Server 2016 (SP2-GDR) (KB4532097) - 13.0.5102.14 (X64)   Dec 31 2019 22:39:35   Copyright (c) Microsoft Corporation  Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2016 Standard 10.0<X64> (Build 14393: ) (Hypervisor)

I have configured SQL Server Database mail but my mail is not sending to recipient.

As per some blogs there were mail issues with SP1 where it should have .NET 3.5 framework should installed but mine is SP2 and it has all the same sign like SP1 mail issue.

When I launch DatabaseMail.exe in binn folder I see this error 

The following feature couldnt be installed

.NET Framework 3.5 (Include .NET 2.0 and 3.0)

As per this workaround 

https://support.microsoft.com/en-gb/help/3186435/sql-server-2016-database-mail-doesn-t-work-when-net-framework-3-5

I opted for Workaround 1 and placed the DatabaseMail.exe.config to same bill folder and now when I launch DatabaseMail.exe Its is opening a black console window, I think that was expectation so I thought now my mail issue is gone but then I still have the issue.

Though the .NET 3.5 Framework issues was related to SP1 but I have the same symptom where as I have SP2.

Help me to get rid this issue.. There are few constraint though .. 

I can not ask for install .NET 3.5 framework as I didn't fine any blog where it is saying the issue could be with SP2 also.

I can not ask for repair SQL Server.

Viewing all 15694 articles
Browse latest View live


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