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

Extended Events large query statements

$
0
0

I need to setup Extended Events sessions on a couple of servers running SQL 2012/2014 Ent.

Session should capture the statements (inside procs/ad-hoc queries/rpcs ) that have the largest impact . 

I do not do the multiple executions with same hash/ analyze at this step , just focusing on largest impact statements/queries.

As I see I should only be capturing the sp_statement_completed, sql_statement_completed, rpc_completed and not the module_end or sql_batch_completed, correct?

I am good with the DDL for it, actions/options/targets, etc, just the set of events to capture the high impact statements/queries.

Thank you,


Monitor SAN Perfmon counters (logical or physical disk counters)

$
0
0

I run Perfmon on Win 2012 R2. Storage is SAN based, hosts are VMWare. Not clear to me if I should use physicalDisk or logicalDisk object counters .

Thank you,


SQL Express question

$
0
0


Hi All,

Need a clarification. I am not seeing BUILTIN\Administrators group under sql logins. Was it removed from any specific version. I am using SQL 2016 Express Edition. 'sa' is also disabled. only windows authentication is turned on.

What are the steps to add a windows user as a sql admin.?

The reason why I am asking this, recently we have got an SQL Express instance which needs to be upgrade (i.e. edition upgrade =Standard) as they hitting 10GB limit on data files. Thats why wanted to know the steps involved to add a user as an sqladmin before performing the edition upgrade.

Also, are there any known issues while performing edition upgrade from SQL2014 express edition to SQL2014 standard edition ?

Thanks,

Sam

OPENQUERY on SSRS

$
0
0
I have two systems , one using MS SQL and the other one using mySQL and so am using a linked server with OPENQUERY on MS SQL to connect to mySQL and read data from mySQL Database. The query works 100% on SSMS "SELECT * FROM OPENQUERY(MYSQL,'SELECT * FROM Transaction')" but if I use the same query on SSRS datasets, I am getting the error message below. Any ideas how I can fix this error? 

querying a database that has replication subscriber tables

$
0
0

Hi we run 2017 standard. 

we are wondering if queries run against replication subscriber tables can interfere (ie block) with the replication process.   and if the opposite is true as well, ie the replication process can block the queries.

and can read committed snapshot isolation be turned on a subscribing (replication) database?...theoretically to avoid any locking that the query (or replication) might create.

we don't really want to query with nolock.

Enable TCP IP and Named Pipes using T-SQL/PowerShell/CMD

$
0
0

Hi,

I would like to enable SQL Server TCP IP and Named pipes using command line or PowerShell? This is for basically SQL Server 2016 Express edition.

Thanks

SQL 2016: Syscommittab - Cleanup Single Transaction Results in significant log run up.

$
0
0
Good Morning All,

Question: Alternate ways to cleanup syscommittab.

Situation:
An abused Change Tracking implementation established pre version upgrade and patching to (13.0.5233.0) and upon removing high transaction side-table resulted in several billion record delete, single transaction upon sys.syscommittab.

Specifically after discontinuing change tracking on the most egregious offending dataset (tens of millions of transactions daily) we found log runup to the order of a terabyte per billion records in sys.syscommittab.  I believe this is a product glitch in how the table is cleaned up and was looking for suggestions beyond what is outlined in cleaning up the side table (e.g. discontinuing change tracking on the offender essentially drops the side table hence no need to clean it up.  Should not side table are the "sys.change_tracking_ObjectID" tables.).

We were contemplating purging in an organized fashion (not in a single transaction as the system was doing but rather in reasonable chunks) directly the sys.syscommittab table.  Specifically we would target records beyond the retention period.  This is after we have performed side-table cleanup such as outlined in https://blogs.msdn.microsoft.com/sql_server_team/change-tracking-cleanup-part-1/.

To add to my question above, has anyone attempted this and if not any thought on what we might expect would be helpful.

Version: SQL Server 2016 Standard SP2 CU4 (13.0.5233.0)
Logging: Full and Mirrored.

Log runup problem has been mentioned numerous times in this and other forums.  It wasn't until we had a very large log run up event that we started to dig to diagnose the problem.

Compounding Symptoms: Checkpoint blocked by "Task Scheduler" which was actually performing the syscommittab cleanup and "CtCleanupTblMetadata".  The process that drove up a pair of log files to their maximum, approximately 4.1 terabytes, then rolled back.   We couldn't add on additional log files to the database to mitigate the 2TB limit per file due to checkpoint being blocked by the syscommittab process.

Thank you in advance for any assistance.

Trace Flag 4199


Getting final column types from Extended Events DMV's

$
0
0

With a query like this.... this is not perfect.... which is the heart of the question.....

I hope, I covered all the necessary five dmv's needed to get the column type level detail.

+++returns too many rows; tried distinct knowing that is not the right way of solving the problem.  Might be missing a join somewhere ++++++++++

select s.name , c.*

from sys.dm_xe_sessions s , sys.dm_xe_session_targets t , sys.dm_xe_packages  p , sys.dm_xe_objects o , sys.dm_xe_object_columns c
where s.address = t.event_session_address and s.name = '
eeDuration'and p.guid = t.target_package_guid and p.guid = o.package_guid
and p.guid = c.object_package_guid and o.type_package_guid = c.type_package_guid

++++++++++++++++++++++++++++++

What I want to get with the above query is the data that are Bolded and Underlinedwithin the following script, so that I can create the final table (from the XML) with appropriate column types, etc.  I don't think these data types are inside the XML (did not even bother to check)…. just want to get them by using the dmv's dynamically.

Also need some help with eventvs. data

drop table if exists eeDuration
go
SELECT event_data = convert(xml, event_data)
INTO eeDuration
 FROM sys.fn_xe_file_target_read_file(N'R:\Mssql\Backup\aStandardManual_0_*.xel', null, null, null);
 go
--SELECT * FROM eeDuration
SELECT
  ts  = event_data.value(N'(event/@timestamp)[1]', N'datetime'),
  [sql]  = event_data.value(N'(event/action[@name="sql_text"]/value)[1]', N'nvarchar(max)'),
  duration  = event_data.value(N'(event/data[@name="duration"]/value)[1]', N'nvarchar(max)'),
  spid  = event_data.value(N'(event/action[@name="session_id"]/value)[1]',N'int'),
  user_nm = event_data.value(N'(event/action[@name="username"]/value)[1]', N'nvarchar(max)'),
  dbname = event_data.value(N'(event/action[@name="database_name"]/value)[1]', N'nvarchar(max)'),
  username = event_data.value(N'(event/action[@name="nt_username"]/value)[1]', N'nvarchar(max)'),
  statement = event_data.value(N'(event/data[@name="statement"]/value)[1]', N'nvarchar(max)')
FROM eeDuration
ORDER BY ts


Travis McGee


Restore is failing ...

$
0
0

Hi Experts,

We are trying to restore a prod database on one of the sub-prod environments. We are doing the restore via sql agent job.
Job is failing and when I see the job history, it shows below message.
There is insufficient free space on disk volume 'E:\' to create the database.
The database requires 636590489600 additional free bytes, while only 206158872576 bytes are available.
[SQLSTATE 42000] (Error 3257)  Problems were identified while planning for the RESTORE statement.

My Question is why does the RESTORE is failing? We are even using WITH REPLACE option which tries to replace existing files and there is around 190 GB free space in drive.
What makes SQL Server tell the user that it needs additional of 636590489600 bytes (593 GB). Can anyone please explain?

Environment details
============================
select @@version
Microsoft SQL Server 2012 (SP4) (KB4018073) - 11.0.7001.0 (X64)
    Aug 15 2017 10:23:29
    Copyright (c) Microsoft Corporation
    Enterprise Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)


--drive info
Currently E: drive allocate space = 4.62 TB , 191 GB Free.


-- Tried to do restore filelistonly
RESTORE filelistonly
FROM DISK='H:\Backup\db_name_Full_20190813_230453.BAK'

-- checked the current file size

select * from master..sysaltfiles
where dbid = db_id('dbname')


Thanks,
Sam



Enable TCP IP and Named Pipes using T-SQL/PowerShell/CMD

$
0
0

Hi,
I am trying to enable TCP/IP and Named Pipes using the following command. But I have encountered the error:--

WMIC /NAMESPACE:\\root\Microsoft\SqlServer\ComputerManagement10 PATH ServerNetworkProtocol Where ProtocolName=’Np’ CALL SetEnable

Invalid Namespace



Thanks

Multiple mdf, empty one is missing

$
0
0

Hi guys i have a big problem. I know i did such stupid and unforgivable mistake. And know please help me if you can. I wanted to make copy of database. I should make it by backup and then restore as another database but faster option was to stop mssql server service, copy files and then attach as new database. The problem is that few minutes eariel i have created new mdf file on primary filegroup in my database i wantedo to copy. That was empty mdf file, just new one. Then i stoped mssql service and deleted that new empty mdf file from hard drive manually. I dont know why, i thought that: "this was just for tests we dont need anymore". When i copied files, i started mssql service and my database is in "recovery Pending" mode and cant find that empty mdf file. Even if i create the same file from another database ofcourde mssql server knows that this is not proper file. I cant make alter table remove file beacuse of error:

Database cannot be opened due to inaccessible files or insufficient memory ordisk space

Is there any possibilities to recover that database? I have backup but i will lost data from one day.

Please help if you can

Query Store option

$
0
0

One option in query store I get very confused .

Statistics Collection Interval

what does it acutally do ? the default interval is 60mins.

so which mean every 60 mins the execution plan will gather once?

Why clusterless AG in sql 2017 not a DR option?

$
0
0

I would like to know why clusterless AG in sql 2017 not a DR solution? Is there a reason that i am missing?

I am ok with async & no auto failover - It's like one type of mirroring option of old.

Pretty much if it came after db mirroring it would be a hit. mirroring + read_only secondaries is what I am seeing it as with no requirement of clustering. So if mirroring was a viable DR solution for so long than why isn't clusterless AG a DR solution.

I want to know as I would like to set it up & use for DR+read_only reporting copies.

I know all about AG etc, but it needs clustering and that is not a option on one of my apps so lets not get into AG & its advantages (ha, dr, grp failovers, listener, read-only routing etc etc.. i know) but my question pertains to one of my apps where i have a mixture of a clustered env & non windows clustering enabled server which needs to be used for reporting and i have tested that I am able to use clusterless ag there where i can add both env as replicas.

https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/configure-read-scale-availability-groups?view=sql-server-2017

we are good with:

  • Forced manual failover with data loss
  • Manual failover without data loss

Please don't reply about adv of AG, keep your answers to why read-scale AG is not a DR option, thanks.


D

SQL Server 2019 CTP 3.0 repair and unistall.

$
0
0

Hi!

I have SQL Server 2017 installed and I tried install SQL Server 2019 side by side.

I made mistake and selected Default Instance for SQL Server 2019. Sql Server installation failed.

and now I am trying to uninstall SQL Server 2019 CTP 3.0

When I do that installation do not even see that SQL Server 2019 CTP 3.0 installed, because it is not installed. (some files are  missing)

So I have damaged version of SQL Server CTP 3.0. Which I have half-installed. 

When I try repair or reinstall SQL Server CTP 3.0 as new Named Instance I am getting this error.

--MSI (s) (48:74) [08:24:00:777]: SECREPAIR: Error determining package source type
--MSI (s) (48:74) [08:24:00:777]: SECUREREPAIR: SecureRepair Failed. Error code: 52435F60620
--MSI (s) (48:74) [08:24:09:892]: Product: Microsoft OLE DB Driver for SQL Server -- Error 1316. The specified account already exists.

When I run uninstall, it does not show that SQL Server is installed.

How to fix broken installation of SQL Server 2019 CTP 3.0


RUV




Database Status: Suspect vs Recovery Pending.

$
0
0

what's the different between database status Suspect vs Recovery Pending. ???

what's are the different causes for both Suspect vs Recovery Pending. ???

Low performance in ApexSql recovery

$
0
0

Hi every one,

I have server for recovering data with apexsql recovery software.the configuration of server is :

Hardware

Core 2.0 GHz CPU ( 2 Socket + 2 Core ) 8 GB memory

100 GB disk space

SQL Server

SQL Server 2016

OS

Windows Server 2016

Software

.NET Framework 4.7.2 

I have problem when I used apexsql recovery for recoveringdata from full backup file. The software works slowly .    I have some error in performance monitoring of server :

how can I  increse performance of apexsql recovery for large databases???






version store space not being released

$
0
0

This morning I tried to shrink a DB file after dropping about 70g of data from it. I ran DBCC SHRINKFILE(1,x) where x was the size I wanted to shrink to. X was slightly larger than the used space in the file.  It ran for approx 3 hours and never completed. I cancelled it because it there is a production DB on this server and my tempdb space was filling up due to version store (this non-prod DB has read committed snapshot isolation enabled). The session I ran shrinkfile on (and subsequently cancelled) disconnected long ago however 4 hours later none of the version store has been released. Is there something I can do to force it to be released short of restarting the server?



Chuck

There is insufficient system memory in resource pool 'internal' to run this query - SQL 2014 SP3

$
0
0

Hi All,

I'm running SQL 2014 SP3 and after July 2019 patching I'm seeing lots of errors relating to memory issues i.e.  There is insufficient system memory in resource pool 'internal' to run this query

This is causing alot of problems executing basic queries and backups are failing

The server itself has plenty of available memory and max memory is set to 65 GB. I noticed from a monitoring tool that we use we observed and a severe degradation in the maximum workspace memory and a massive increase in pages allocated to memoryclerk_SOSNODE.  This all occurred after installed July 2019 updates KB4504418, KB4507448, KB506996 & KB507005

Do you think the updates have caused a memory leak, We are planning to install SP3 CU3 later this week

Below is the output from DBCC MEMORYSTATUS

Process/System Counts                   Value

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

Available Physical Memory               165309018112

Available Virtual Memory                140583747022848

Available Paging File                   201184542720

Working Set                             1112621056

Percent of Committed Memory in WS       99

Page Faults                             9545792

System physical memory high             1

System physical memory low              0

Process physical memory low             1

Process virtual memory low              0

(10 row(s) affected)

Memory Manager                          KB

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

VM Reserved                             149521168

VM Committed                            1172256

Locked Pages Allocated                  64049508

Large Pages Allocated                   0

Emergency Memory                        1024

Emergency Memory In Use                 16

Target Committed                        67108872

Current Committed                       65221768

Pages Allocated                         63602752

Pages Reserved                          -852016

Pages Free                              125264

Pages In Use                            63571528

Page Alloc Potential                    181896

NUMA Growth Phase                       2

Last OOM Factor                         1

Last OS Error                           0

(16 row(s) affected)

Memory node Id = 0                      KB

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

VM Reserved                             117265664

VM Committed                            1170680

Locked Pages Allocated                  31385924

Pages Allocated                         31137760

Pages Free                              46824

Target Committed                        33554424

Current Committed                       32556608

Foreign Committed                       0

Away Committed                          0

Taken Away Committed                    0

(10 row(s) affected)

Memory node Id = 1                      KB

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

VM Reserved                             32255440

VM Committed                            1556

Locked Pages Allocated                  32663584

Pages Allocated                         32464992

Pages Free                              78440

Target Committed                        33554424

Current Committed                       32665144

Foreign Committed                       0

Away Committed                          0

Taken Away Committed                    0

(10 row(s) affected)

Memory node Id = 64                     KB

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

VM Reserved                             0

VM Committed                            20

Locked Pages Allocated                  0

(3 row(s) affected)

MEMORYCLERK_SQLGENERAL (node 0)         KB

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

VM Reserved                             0

VM Committed                            0

Locked Pages Allocated                  0

SM Reserved                             0

SM Committed                            0

Pages Allocated                         20568

(6 row(s) affected)

MEMORYCLERK_SQLGENERAL (node 1)         KB

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

VM Reserved                             0

VM Committed                            0

Locked Pages Allocated                  0

SM Reserved                             0

SM Committed                            0

Pages Allocated                         352

(6 row(s) affected)

MEMORYCLERK_SQLGENERAL (Total)          KB

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

VM Reserved                             0

VM Committed                            0

Locked Pages Allocated                  0

SM Reserved                             0

SM Committed                            0

Pages Allocated                         20920

(6 row(s) affected)

MEMORYCLERK_SQLBUFFERPOOL (node 0)      KB

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

VM Reserved                             13634884

VM Committed                            524288

Locked Pages Allocated                  287548

SM Reserved                             0

SM Committed                            0

Pages Allocated                         1378936

(6 row(s) affected)

MEMORYCLERK_SQLBUFFERPOOL (node 1)      KB

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

VM Reserved                             0

VM Committed                            0

Locked Pages Allocated                  0

SM Reserved                             0

SM Committed                            0

Pages Allocated                         146128

(6 row(s) affected)

MEMORYCLERK_SQLBUFFERPOOL (Total)       KB

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

VM Reserved                             13634884

VM Committed                            524288

Locked Pages Allocated                  287548

SM Reserved                             0

SM Committed                            0

Pages Allocated                         1525064

(6 row(s) affected)

MEMORYCLERK_SQLQUERYEXEC (node 0)       KB

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

VM Reserved                             0

VM Committed                            0

Locked Pages Allocated                  0

SM Reserved                             0

SM Committed                            0

Pages Allocated                         280

(6 row(s) affected)

MEMORYCLERK_SQLOPTIMIZER (node 0)       KB

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

VM Reserved                             0

VM Committed                            0

Locked Pages Allocated                  0

SM Reserved                             0

SM Committed                            0

Pages Allocated                         1848

(6 row(s) affected)

MEMORYCLERK_QUERYDISKSTORE (node 0)     KB

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

VM Reserved                             0

VM Committed                            0

Locked Pages Allocated                  0

SM Reserved                             0

SM Committed                            0

Pages Allocated                         1432

(6 row(s) affected)

MEMORYCLERK_SQLUTILITIES (node 0)       KB

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

VM Reserved                             0

VM Committed                            0

Locked Pages Allocated                  0

SM Reserved                             0

SM Committed                            0

Pages Allocated                         248

(6 row(s) affected)

MEMORYCLERK_SQLUTILITIES (node 1)       KB

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

VM Reserved                             0

VM Committed                            0

Locked Pages Allocated                  0

SM Reserved                             0

SM Committed                            0

Pages Allocated                         16

(6 row(s) affected)

MEMORYCLERK_SQLUTILITIES (Total)        KB

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

VM Reserved                             0

VM Committed                            0

Locked Pages Allocated                  0

SM Reserved                             0

SM Committed                            0

Pages Allocated                         264

(6 row(s) affected)


SQL alwayON on machines with two SQL instances

$
0
0

I have two SQL servers with two instances each (2012 and 2016), both machine are in windows 2012 fail over cluster. I am able to have the named instance (2016) created Alwayson group and the listener with a port 5023. it works fine. but I cannot get the default instance to have the AlwaysON group working, the AlwaysOn group created and the listener created on 5022(later tried 5024....), but the secondary always shows disconnected. I tried swap the two nodes for primary and secondary, no luck.

replica_server_nameendpoint_urlconnected_state_desclast_connect_error_descriptionlast_connect_error_numberlast_connect_error_timestamp
mySecondaryServer    TCP://mySecondaryServer.esclhin.on.ca:5024DISCONNECTEDNULLNULLNULL

myPrimaryServer TCP://myPrimaryServer .esclhin.on.ca:5024CONNECTEDNULLNULLNULL

Does it support two instances on a machine for AlwaysON group?

Viewing all 15264 articles
Browse latest View live


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