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

How do I see the full SQLl/Query text of a spid?

$
0
0

How do I see the full SQLl/Query text of a spid?

I use different ways to get the query, the problem is it truncates the end, so I cannot see the entire query/sql text. Is there another way to a query/sql text that is being run?


Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
Praveen Dsa | MCITP - Database Administrator 2008 | My Blog | My Page


Encountered fatal system assertion check involving CLR UDF, calculated column, and columnstore index.

$
0
0

We encountered a situation where a table has a calculated column that uses a scalar user-defined function (UDF) defined AS an EXTERNAL NAME (is contained in a custom assembly) that returns an NVARCHAR(MAX) and the table has a nonclustered columnstore index that includes the column that is passed into the function of the calculated column, a fatal system assertion check occurs (Msg 596, Level 21, State 1).

We encountered this behavior in versions 14.0.3045.24, 14.0.3048.4, and 14.14.0.3049.1.  We have not checked other versions.

Altering the return of the UDF function from NVARCHAR(MAX) to NVARCHAR(64) results in the successful execution of queries that use the calculated column and the fatal system assertion check no longer occurs.

Perhaps something can be done to warn of or prevent the combination of columnstore indexes including columns that participate in UDF calculations that return NVARCHAR(MAX) at the time the index or the calculated column is created.

The following TSQL describes the scenario:

/*** In our implementation this CLR UDF removes all non-alphanumeric characters,
 though we found that the logic here doesn't affect the issue. It can return the
 string without modification and the issue still occurs. ***/
CREATE FUNCTION [per].[SimplifyPersonName]
(@str NVARCHAR (MAX))
RETURNS NVARCHAR (MAX)
AS
 EXTERNAL NAME [AssemblyName].[UserDefinedFunctions].[SimplifyPersonName];
GO

CREATE TABLE [per].[Person](
    [person_id] UNIQUEIDENTIFIER NOT NULL,
    [family_name] NVARCHAR(64) NULL,
    [given_name] NVARCHAR(64) NULL,
    [given_name_simple]  AS ([per].[SimplifyPersonName]([given_name])),
    [family_name_simple]  AS ([per].[SimplifyPersonName]([family_name])),
 CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED ([person_id] ASC)
);
GO

CREATE NONCLUSTERED COLUMNSTORE INDEX [CSIX_Person] ON [per].[Person]
(
    [person_id],
    [family_name],
    [given_name]    
)WITH (DROP_EXISTING = OFF, COMPRESSION_DELAY = 0) ON [INDEX]
GO

SELECT COUNT(p.person_id)
FROM per.Person p
WHERE (SUBSTRING(UPPER(p.[family_name_simple]),1,1)) <= N'Z'

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?

SQL CTE with 8 million rows and PIVOT

$
0
0
--Trying to see if there is a better way of handling this SQL code.  This view will be leveraged in a Power BI report but we are trying to query over 8 million rows and never returns.  We have added indexes but still no luck. How can this view be optimized or rewritten? 


ALTER VIEW [dbo].[vw_RawDataEntityReport]
AS 
WITH CTE_Rawdata
AS (SELECT AG.[Name] AS [Account Group],
           ACC.Id AS [Account ID],
           ACC.[Name] AS [Account Description],
           CASE
               WHEN ACD.IsForBeginningOfYearForTaxCalculation = 1 THEN
                   'B'
               ELSE
                   'E'
           END AS [Beginning/Ending],
           ACD.Amount,
           CASE
               WHEN J.IsIncludedInEverywhereTotal = 1 THEN
                   ACD.Amount
               ELSE
                   0
           END AS Amount2,
           J.StateId AS JurisdictionName,
           FP.TaxYearId AS [Tax Year],
           FP.[Name] AS [Short Year],
           LE.SourceEntityId AS [Display Entity ID],
           LE.[Name] AS [Entity Name],
           CAST(LE.SourceEntityId AS VARCHAR(20)) + '-' + LE.[Name] AS [Entity]
    FROM SWP.AccountData ACD
        LEFT JOIN SWP.Account ACC
            ON ACC.Id = ACD.AccountId
        LEFT JOIN SWP.AccountGroup AG
            ON AG.Id = ACC.AccountGroupId
        LEFT JOIN SWP.FilingDecision FD
            ON FD.Id = ACD.FilingDecisionId
        LEFT JOIN SWP.Jurisdiction J
            ON J.Id = FD.JurisdictionId
        LEFT JOIN SWP.FilingPeriod FP
            ON FP.Id = FD.FilingPeriodId
        LEFT JOIN SWP.LegalEntity LE
            ON LE.Id = FD.LegalEntityId)
SELECT [Account Group],
       [Account ID],
       [Account Description],
       [Tax Year],
       [Short Year] AS [Filing Period],
       [Display Entity ID],
       [Entity Name],
       [Entity],
       [Beginning/Ending],
       [EV],
       [AL],
       [AK],
       [AZ],
       [AR],
       [CA],
       [CO],
       [CT],
       [DE],
       [DC],
       [FL],
       [GA],
       [HI],
       [ID],
       [IL],
       [IN],
       [IA],
       [KS],
       [KY],
       [LA],
       [ME],
       [MD],
       [MA],
       [MI],
       [MN],
       [MS],
       [MO],
       [MT],
       [NE],
       [NV],
       [NH],
       [NJ],
       [NM],
       [NY],
       [NYC],
       [NC],
       [ND],
       [OH],
       [OK],
       [OR],
       [PA],
       [RI],
       [SC],
       [SD],
       [TN],
       [TX],
       [UT],
       [VT],
       [VA],
       [WA],
       [WV],
       [WI],
       [WY],
       [RQ],
       [OT],
       [O1],
       [O2],
       [O3],
       [O4]
FROM
(
    SELECT CTRD.[Account Group],
           CTRD.[Account ID],
           CTRD.[Account Description],
           CTRD.[Tax Year],
           CTRD.[Short Year],
           CTRD.[Display Entity ID],
           CTRD.[Entity Name],
           CTRD.[Entity],
           CTRD.[Beginning/Ending],
           CTRD.JurisdictionName,
           SUM(Amount) AS Amount
    FROM CTE_Rawdata CTRD
    GROUP BY CTRD.[Account Group],
             CTRD.[Account ID],
             CTRD.[Account Description],
             CTRD.[Tax Year],
             CTRD.[Short Year],
             CTRD.[Display Entity ID],
             CTRD.[Entity Name],
             CTRD.[Entity],
             CTRD.[Beginning/Ending],
             CTRD.JurisdictionName
    UNION ALL
    SELECT CTRD.[Account Group],
           CTRD.[Account ID],
           CTRD.[Account Description],
           CTRD.[Tax Year],
           CTRD.[Short Year],
           CTRD.[Display Entity ID],
           CTRD.[Entity Name],
           CTRD.[Entity],
           CTRD.[Beginning/Ending],
           'EV' AS JurisdictionName,
           SUM(Amount2) AS Amount
    FROM CTE_Rawdata CTRD
    GROUP BY CTRD.[Account Group],
             CTRD.[Account ID],
             CTRD.[Account Description],
             CTRD.[Tax Year],
             CTRD.[Short Year],
             CTRD.[Display Entity ID],
             CTRD.[Entity Name],
             CTRD.[Entity],
             CTRD.[Beginning/Ending]
) A
PIVOT
(
    SUM(A.Amount)
    FOR JurisdictionName IN ([EV], [AL], [AK], [AZ], [AR], [CA], [CO], [CT], [DE], [DC], [FL], [GA], [HI], [ID], [IL],
                             [IN], [IA], [KS], [KY], [LA], [ME], [MD], [MA], [MI], [MN], [MS], [MO], [MT], [NE], [NV],
                             [NH], [NJ], [NM], [NY], [NYC], [NC], [ND], [OH], [OK], [OR], [PA], [RI], [SC], [SD], [TN],
                             [TX], [UT], [VT], [VA], [WA], [WV], [WI], [WY], [RQ], [OT], [O1], [O2], [O3], [O4]
                            )
) AS pivotted

Connecting to SQL Server without instance name

$
0
0
This is probably something basic I'm overlooking, but... I have a 2017 database engine on a named instance with non-default port.  So connection string should be ServerName\InstanceName, xxxx.  I can connect from a remote Management Studio without providing instanceName - just ServerName, xxxx.  I noticed SQL Browser was running, so I disabled it.  however, I can still connect without InstanceName.  How do I ensure InstanceName is required in the connection?  Thanks.

high logical fragmentation on disk but the disk is 99% empty

$
0
0

hi, I'm not sure if its the right forum and if it is not the right one, please point me to the right forum.

I have a server with os 2012 R2 & SQL server 2012, used for small application with a little number of writes, so temp DB is very small and the transaction log is small also... 

the Tlog located in a different drive from the Data and the Temp DB is also in a different drive...

lately, I started to get warnings and errors from scom about 100% fragmentation in the logical disk, and when I entered the server I saw that drive T (TempDB) and drive L (Log) has 100% fragmentation in the "optimizing hard-drives", but when I looked inside of them I saw that the HD are 99% empty (for example from 10GB, only 100mb in use).

can someone explain to me what does this fragmentation means and how it is on 100% if the drive is 99 empty?

and I would like to know how to treat fragmentation on SQL server's drives, can it affect the SQL? do I need to ignore it? and what about the task of Microsoft doing defrag in the task scheduler, if it is not affecting the SQL, so can I do it also without fear of destroying the SQL?

How to add new db to existed maintenance plan

$
0
0

Hi,

I am using sql2014. Created transaction log backup back maintenance plan for some of the databses. now i would like to add one more new database to existing tlogbackup maintenance plan. 

when i tried edit the existed maintenance plan and selected the "these databses' but i am not able to see any database list in it. i am not able to understand what could be the issue.

please help how to add new databse to existed maintenanceplan.

Thanks,

Jo.


pols

Non-clustered indexes as Primary Keys

$
0
0

Hi everyone

I have noticed on a newly acquired instance that there are a number of tables with primary keys that have non-clustered indexes on them.

What would be the use case and/or reason for this to happen? Why wouldn't it be a clustered key?

Many thanks in advance for assistance.


can one sql agent start two tasks in parallel?

$
0
0
Hi we run 2016 enterprise. I'd like one sql agent item to start tasks a and b so that a and b run in parallel. Is that possible?

Functions and Recompile

$
0
0

All,

We have a database on SQLServer 2012 which is more of a Decision Support System. Users submit huge amount of data that needs to be processed by the database engine.

Given the nature of the application and its purpose, each user's parameter values is drastically different and the number of rows affected by the parameters also changes dynamically.

Because of this in the SPs, we have used WITH RECOMPILE option. It works fine but in some cases we have noticed performance issues on SQL functions as well. However, unlike SPs there is no WITH RECOMPILE option. Is there a way to RECOMPILE the functions runtime?

Thanks

rgn

Unicode/chinese characters in audit log

$
0
0

I have a Microsoft SQL Server 2016 (SP2-CU2-GDR) (KB4458621) - 13.0.5201.2 (X64) with change tracking enabled for several tables.

Sometimes I see an expected error message like this a valid table name in the audit logs.

Change Tracking autocleanup is blocked on side table of "sometable". If the failure persists, check if the table "sometable" is blocked by any process. 

I have several entries where the table name listed is incorrect/nonexistent. example:

Change Tracking autocleanup is blocked on side table of "ᖬᔸᓄᑐᏜ፨ዴኀሌᆘᄤႰြ࿈པ໠๬෸඄ഐಜనழୀૌ੘৤॰ࣼ࢈ࠔޠܬڸلא՜ӨѴЀΌ̘ʤȰƼňÔ`". If the failure persists, check if the table "ᖬᔸᓄᑐᏜ፨ዴኀሌᆘᄤႰြ࿈པ໠๬෸඄ഐಜనழୀૌ੘৤॰ࣼ࢈ࠔޠܬڸلא՜ӨѴЀΌ̘ʤȰƼňÔ`" is blocked by any process .

Why would these random unicode characters appear in the log?

Performance Counter Alerts - Which Counters and their thresholds?

$
0
0
I know there are many counters for creating data collector sets in PerfMon, both SQL-specific counters and general system ones.   But for Performance Counter Alerts, what is the short list of counters to start with, and their thresholds?  I don't think I need to alert on all of the counters.  I searched for Performance Counter Alert Best Practice, but didn't come up with a source that shows the most useful.  Thanks.

obfuscating automatically

$
0
0

Hi we run 2016 enterprise. I see a pretty good article at https://www.red-gate.com/simple-talk/sql/database-administration/obfuscating-your-sql-server-data/ (a bit dated) and cant help but wonder if there are more modern techniques for scrambling data in a dev environ.

My hope is to find something that will scramble notes and perhaps scores about/given to peoples' performance.  But not to scramble their id's or names because of all the systems that need that info to be "as is" in production.

what I think would be really cool is if in our dev environ, I could create certain tables with some sort of sql feature turned on certain cols so sql knows to scramble those fields when they get loaded.

is there such a thing?  Does anyone know of a really relevant article on the subject?  Perhaps one that really gets to the point?

 

Merge on temporal table fails with Attempting to set a non-NULL-able column's value to NULL

$
0
0

Workflow:

  1. Create temporal table with default history table in a data warehouse
  2. Create an index on the history table
  3. Perform merge statements against the temporal table on an hourly basis
  4. Notice sometimes the error will produce: Attempting to set a non-NULL-able column's value to NULL
  5. Drop the index from the history table
  6. Perform the merge with the same data set, and it will be successful
  7. Recreate the index on the history table
  8. Randomly the error will generate again, repeat steps 5 thru 7

On April 29th I created a new temporal table named [dbo].[FactPersonnelScheduleDetails_Current] with a default history table named [History].[FactPersonnelScheduleDetails_Current].

This table is in a data warehouse that performs several merge statements on an hourly basis.

Twice now since implementing this table 4 days ago, the merge transaction has failed with the following error: "Attempting to set a non-NULL-able column's value to NULL"

The History table has one user-defined index. As soon as I drop that index, I can the successfully complete the merge.

Any suggestions why the MERGE is failing when I have a user defined index created on the history table, but works when I remove the user defined index?

CREATE TABLE [dbo].[FactPersonnelScheduleDetails_Current] ( 
[ScheduleCellKey]                    INT                NOT NULL,
[ScheduleCellID]                     INT                NOT NULL,
[DBID]                               SMALLINT           NOT NULL,
[ScheduleDetailsID]                  INT                NOT NULL,
[RecordNumber]                       SMALLINT               NULL,
[WorkDate]                           DATE                   NULL,
[WorkDateKey]                        INT                    NULL,
[WeekStartDate]                      DATE                   NULL,
[DayOfTheWeek]                       VARCHAR(50)            NULL,
[WorkDayNumber]                      TINYINT                NULL,
[MasterScheduleCellKey]              INT                    NULL,
[WorkingScheduleMatchesMasterScheduleFlag] VARCHAR(3)       NULL,
[DateWorkingScheduleNoLongerMatchesMaster] DATETIME2(7)     NULL,
[IsHoliday]                          VARCHAR(3)             NULL,
[JobPostDetailID]                    INT                    NULL,
[JobPostDetailKey]                   INT                    NULL,
[JobNumber]                          VARCHAR(10)        NOT NULL,
[JobKey]                             INT                NOT NULL,
[JobTierKey]                         INT                NOT NULL,
[EmployeeNumber]                     INT                    NULL,
[EmployeeKey]                        INT                    NULL,
[CategoriesDetailID]                 INT                    NULL,
[BillCategory]                       VARCHAR(50)            NULL,
[HoursTypeID]                        SMALLINT               NULL,
[HoursTypeDescription]               VARCHAR(50)            NULL,
[PaycheckDescriptionId]              SMALLINT               NULL,
[PaycheckDescription]                VARCHAR(50)            NULL,
[RecordTypeID]                       TINYINT                NULL,
[Hours]                              DECIMAL(19,4)          NULL,
[InTime]                             TIME(3)                NULL,
[InTimeString]                       VARCHAR(8)             NULL,
[InDateTime]                         DATETIME               NULL,
[OutTime]                            TIME(3)                NULL,
[OutTimeString]                      VARCHAR(8)             NULL,
[OutDateTime]                        DATETIME               NULL,
[LunchHours]                         DECIMAL(19,4)          NULL,
[NextDay]                            VARCHAR(3)         NOT NULL,
[PayRate]                            MONEY                  NULL,
[SpecialPayRate]                     VARCHAR(3)         NOT NULL,
[ForceOTToThisJob]                   VARCHAR(3)         NOT NULL,
[OvertimeHours]                      DECIMAL(19,4)          NULL,
[DoubletimeHours]                    DECIMAL(19,4)          NULL,
[InvoiceNumber]                      INT                    NULL,
[InvoiceDescription]                 VARCHAR(100)           NULL,
[TierDescription]                    VARCHAR(100)           NULL,
[BillRate]                           MONEY                  NULL,
[SpecialBillRate]                    VARCHAR(3)         NOT NULL,
[BillingPayRate]                     MONEY                  NULL,
[NonBillableTypeID]                  SMALLINT               NULL,
[NonBillableTypeDescription]         VARCHAR(50)            NULL,
[LastChangedBy]                      VARCHAR(20)            NULL,
[LastChangedDate]                    DATETIME               NULL,
[DaysBetweenWorkDateAndModifiedDate] INT                    NULL,
[UpdatedToTKHours]                   VARCHAR(3)             NULL,
[SpecialInvoiceDescription]          VARCHAR(3)             NULL,
[SpecialTierDescription]             VARCHAR(3)             NULL,
[InvoiceDetailID]                    INT                    NULL,
[TTMStatusID]                        INT                    NULL,
[IsConfirmed]                        VARCHAR(3)             NULL,
[DateConfirmed]                      DATETIME               NULL,
[IsPublished]                        VARCHAR(3)             NULL,
[AcceptedTypeForPSTT]                TINYINT                NULL,
[TeamTimeAcceptedTypeDescription]    VARCHAR(50)            NULL,
[UserName]                           VARCHAR(20)            NULL,
[DateChanged]                        datetime               NULL,
[Notes]                              VARCHAR(255)           NULL,
[SystemNotes]                        VARCHAR(8000)          NULL,
[ETLDateChanged]                     DATETIME2(7)       NOT NULL DEFAULT (sysdatetime()),
[RecordInsertTimestamp]              DATETIME2(7)       NOT NULL DEFAULT (sysdatetime()),
[RecordUpdateTimestamp]              DATETIME2(7)       NOT NULL DEFAULT (sysdatetime()),
SysStartTime datetime2(0) GENERATED ALWAYS AS ROW START CONSTRAINT DF_SysStart DEFAULT SYSUTCDATETIME(),
SysEndTime datetime2(0) GENERATED ALWAYS AS ROW END CONSTRAINT DF_SysEnd DEFAULT CONVERT(datetime2 (0), '9999-12-31 23:59:59'),
PERIOD FOR SYSTEM_TIME (SysStartTime, SysEndTime),
CONSTRAINT PK_FactPersonnelScheduleDetails_Current PRIMARY KEY NONCLUSTERED (ScheduleCellKey))
WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = History.FactPersonnelScheduleDetails_Current));

CREATE CLUSTERED INDEX [IX01_FactPersonnelScheduleDetails_Current]
ON [dbo].[FactPersonnelScheduleDetails_Current] (WorkDateKey,DBID);

CREATE NONCLUSTERED INDEX [IX02_FactPersonnelScheduleDetails_Current]
ON [dbo].[FactPersonnelScheduleDetails_Current] (JobKey)
INCLUDE (ScheduleCellKey,DBID,WeekStartDate,JobTierKey,EmployeeKey,Hours,WorkingScheduleMatchesMasterScheduleFlag);

CREATE NONCLUSTERED INDEX [IX03_FactPersonnelScheduleDetails_Current]
ON [dbo].[FactPersonnelScheduleDetails_Current] (RecordUpdateTimestamp,MasterScheduleCellKey)
INCLUDE (ScheduleCellKey,WeekStartDate,DayOfTheWeek,JobPostDetailKey,JobKey,EmployeeKey,CategoriesDetailID,Hours,InTime,OutTime,NextDay,PayRate,SpecialPayRate,ForceOTToThisJob,BillRate,SpecialBillRate,NonBillableTypeID,ETLDateChanged,RecordNumber,WorkingScheduleMatchesMasterScheduleFlag);

CREATE NONCLUSTERED INDEX [IX04_FactPersonnelScheduleDetails_Current]
ON [dbo].[FactPersonnelScheduleDetails_Current] (WorkingScheduleMatchesMasterScheduleFlag)
INCLUDE (ScheduleCellKey,DBID,WeekStartDate,JobKey,JobTierKey,EmployeeKey,DateWorkingScheduleNoLongerMatchesMaster);

CREATE NONCLUSTERED INDEX [IX01_FactPersonnelScheduleDetails_Current]
ON [History].[FactPersonnelScheduleDetails_Current] (WorkDateKey,DBID)
INCLUDE (ScheduleCellKey,WeekStartDate,JobKey,JobTierKey,EmployeeKey,Hours,SysStartTime,SysEndTime);

Function call through Linked Server returns wrong value

$
0
0

I have a SQL Server agent job that runs daily, and the first step is to check that a required process finished on another server.  This check is done through a function, which I'm calling through openquery and a linked server.  The job also uses a bit of dynamic sql to add needed parameters:

set @command = 'SELECT @result = [ReturnValue]  from openquery([amlidw],''select [amlidw].[dbo].[process_control_checkrun](''''' + @parent_process_key + ''''',''''' + @child_process_key + ''''',' + ISNULL('''''' + @parent_process_key2+ '''''','default') + ',default) AS [ReturnValue]'') '


exec sp_executesql @command,N'@result int output',@result=@result output

This function will run correctly, and return the correct results for several days.  Then it will start returning 0 when the correct value is 1.  I have even gone so far as to use SQL Server Profiler to check the query being sent, then run it myself on the target server.  In this case it correctly returns 1 on the target server, but the openquery version returns 0.

The only way I can get the correct results again is to make a trivial change to the query.  For instance, I can change the name of the return value to ReturnValueTest, and the function will return correct results for several days.  This would suggest that the return value is somehow being cached until the text changes.

What is going on here?  Is there a way to ensure that the results will be returned correctly across servers?  I could experiment with different way to call the function, but not knowing the cause, I don't exactly know what to do differently.

Both severs in this scenario are SQL Server 2017, and the linked server provider is SQLOLEDB.  Thanks for any insight this group may have.  This one really has me stumped.

  

How to get list of columns in the server that has at least one NULL or BLANK value

$
0
0

Hello there,

I am trying to find all the columns that has at least one NULL or BLANK values. My output should be DB Name, Table Name, Column Name. This will be related to data in the table and not a related to finding if the column allows null or not. Please let me know if anyone has any T-SQL query for the same which can be executed in the server to fetch all these required details.

Thanks,

Palash

deadlock frequently happen

$
0
0

deadlock happen V.frequently, how to prevent from this, deadlock grap xml attached

<deadlock><victim-list><victimProcess id="process55c2667468" /></victim-list><process-list><process id="process55c2667468" taskpriority="0" logused="13568900" waitresource="KEY: 7:72057595418116096 (34f0ad269d12)" waittime="22236" ownerId="326851186" transactionname="UPDATE" lasttranstarted="2019-01-13T19:51:44.240" XDES="0x5b9e81b880" lockMode="X" schedulerid="6" kpid="5148" status="suspended" spid="90" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2019-01-13T18:15:14.837" lastbatchcompleted="2019-01-13T18:15:14.837" lastattention="1900-01-01T00:00:00.837" clientapp="SQLAgent - TSQL JobStep (Job 0xBF20AF18F172984A881F632A2F7007A0 : Step 2)" hostname="SQL-act" hostpid="3964" loginname="NT AUTHORITY\NETWORK SERVICE" isolationlevel="read committed (2)" xactid="326851186" currentdb="7" currentdbname="act" lockTimeout="4294967295" clientoption1="671219744" clientoption2="128056"><executionStack><frame procname="act.dbo.t_invoices_po_journal" line="12" stmtstart="698" stmtend="1508" sqlhandle="0x03000700ee24757b93c0320168a5000000000000000000000000000000000000000000000000000000000000">
with source as (
	select ojorder_number from inserted where ojorder_number is not null
	union
	select ojorder_number from deleted where ojorder_number is not null
)
merge into po_order_deductions_processing_queue as target
using source
on source.ojorder_number = target.id
when matched then update set ts = getdate()
when not matched then insert (id,source)values(source.ojorder_number,'invoice')    </frame><frame procname="act.dbo.sp_inventory_master" line="226" stmtstart="15266" stmtend="16702" sqlhandle="0x0300070014fc2b3f5ffa1b0198a9000001000000000000000000000000000000000000000000000000000000">
with a as (
	select po.oid,po.ref_number,i.Merchandise_Total,round(sum(isnull(nullif(poi.unit_cost_oj,0),poi.unit_cost) * poi.qty),2) mdse
	from invoices i 
	join [sql.commercedb.com].commercedb.dbo.purchase_order po on po.oid = i.OJOrder_Number
	join [sql.commercedb.com].commercedb.dbo.purchase_order_items poi on poi.poid = po.id
	where i.VendorID = 184
	group by po.oid,po.ref_number,i.Merchandise_Total
	having i.Merchandise_Total &lt;&gt; round(sum(isnull(nullif(poi.unit_cost_oj,0),poi.unit_cost) * poi.qty),2)
) 
update i set Merchandise_Total = a.mdse, [Total Invoice] = a.mdse
from invoices i 
join a on a.oid = i.OJOrder_Number and i.Invoice_Number =  concat('EST ',a.ref_number)
where i.VendorID = 18    </frame><frame procname="adhoc" line="1" stmtend="46" sqlhandle="0x0100070051381f0560decb8c5b00000000000000000000000000000000000000000000000000000000000000">
exec sp_inventory_maste    </frame></executionStack><inputbuf>
exec sp_inventory_master   </inputbuf></process><process id="process6a33c23c28" taskpriority="0" logused="17465596" waitresource="KEY: 7:72057595418116096 (7264c9362d21)" waittime="530" ownerId="326851289" transactionname="user_transaction" lasttranstarted="2019-01-13T19:51:45.413" XDES="0x5c31c177e0" lockMode="X" schedulerid="8" kpid="10412" status="suspended" spid="71" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2019-01-13T19:52:33.393" lastbatchcompleted="2019-01-13T19:52:33.390" lastattention="1900-01-01T00:00:00.390" clientapp="SQL-L-1_commercedb_commercedb_tran_pub" hostname="SQL-L-1" hostpid="8608" loginname="cloudvm\SQL-L-1$" isolationlevel="read committed (2)" xactid="326851289" currentdb="8" currentdbname="commercedb" lockTimeout="4294967295" clientoption1="671219744" clientoption2="128056"><executionStack><frame procname="commercedb.dbo.t_purchase_order_po_journal_queue" line="5" stmtstart="250" stmtend="990" sqlhandle="0x03000800a34e6c693576cc0039a8000000000000000000000000000000000000000000000000000000000000">
with source as (
		select oid from inserted where oid is not null
		union
		select oid from deleted where oid is not null
	)
	merge into act.dbo.po_order_deductions_processing_queue as target
	using source
	on source.oid = target.id
	when matched then update set ts = getdate()
	when not matched then insert (id,source)values(source.oid,'purchase_order')    </frame><frame procname="commercedb.dbo.t_purchase_order_items_po_journal_queue" line="5" stmtstart="262" stmtend="714" sqlhandle="0x03000800f8e18f663276cc0039a8000000000000000000000000000000000000000000000000000000000000">
with source as (
	select poid from inserted where poid is not null
	union
	select poid from deleted where poid is not null
)
update p set status_date = p.status_date
from purchase_order p join source on source.poid = p.i    </frame><frame procname="commercedb.dbo.sp_MSupd_dbopurchase_order_items" line="3" stmtstart="1428" stmtend="6238" sqlhandle="0x03000800d47bda19f74b25012da9000001000000000000000000000000000000000000000000000000000000">
update [dbo].[purchase_order_items] set     [poid] = case substring(@bitmap,1,1) &amp; 2 when 2 then @c2 else [poid] end,     [itemid] = case substring(@bitmap,1,1) &amp; 4 when 4 then @c3 else [itemid] end,     [qty] = case substring(@bitmap,1,1) &amp; 8 when 8 then @c4 else [qty] end,     [unit_cost] = case substring(@bitmap,1,1) &amp; 16 when 16 then @c5 else [unit_cost] end,     [qty_received] = case substring(@bitmap,1,1) &amp; 32 when 32 then @c6 else [qty_received] end,     [external_sku] = case substring(@bitmap,1,1) &amp; 64 when 64 then @c7 else [external_sku] end,     [external_id] = case substring(@bitmap,1,1) &amp; 128 when 128 then @c8 else [external_id] end,     [unit_cost_oj] = case substring(@bitmap,2,1) &amp; 1 when 1 then @c9 else [unit_cost_oj] end,     [ojc_record_last_updated_ts] = case substring(@bitmap,2,1) &amp; 2 when 2 then @c10 else [ojc_record_last_updated_ts] end,     [unit_cost_oj_exp_date] = case substring(@bitmap,2,1) &amp; 4 when 4 then @c11 else [unit_cost_oj_exp_date] end,     [unit_cost_oj_promo_code] = case sub    </frame></executionStack><inputbuf>
Proc [Database Id = 8 Object Id = 433748948]   </inputbuf></process></process-list><resource-list><keylock hobtid="72057595418116096" dbid="7" objectname="act.dbo.po_order_deductions_processing_queue" indexname="PK__po_order__3213E83F020C233A" id="lock5784d4e100" mode="X" associatedObjectId="72057595418116096"><owner-list><owner id="process6a33c23c28" mode="X" /></owner-list><waiter-list><waiter id="process55c2667468" mode="X" requestType="wait" /></waiter-list></keylock><keylock hobtid="72057595418116096" dbid="7" objectname="act.dbo.po_order_deductions_processing_queue" indexname="PK__po_order__3213E83F020C233A" id="lock599ecdff00" mode="X" associatedObjectId="72057595418116096"><owner-list><owner id="process55c2667468" mode="X" /></owner-list><waiter-list><waiter id="process6a33c23c28" mode="X" requestType="wait" /></waiter-list></keylock></resource-list></deadlock>

Database is getting too big

$
0
0

We're currently running into some performance problems since our database is getting too big. Due to db size is increasing application cannot handle load and getting hang sometimes.

Database size: 16421 mb Log size: 505.0625 mb Total size: 16926.0625 mb

Recovery model: Simple Disk: C drive with 32.33 percent free space Datafile: Autogrowth is on. Growth value: 128 in units of 8 kb pages. Logfile: Will grow to a max size of 2 TB. Growth value: 10 %. Autogrow setting for db: 1024 kb.


sunnybabu

SQLServer 2017 Developer edition engine service stopped working after the update kb293803

High consumed 99% CPU on SQL server

$
0
0

Hi I have been notice that SQL Server 99% touching . Checked  dead lock.  some of SQLs consumed CPUS but  ave cpu ms is very law . (reports->Standred reports->top sql total cpu time). Check with activity monitor , jobs are suspending - runnable. nothing much. I need to understand why this behaviour .

Version SQL Server 2014 SE

Viewing all 12963 articles
Browse latest View live


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