Tuesday, February 25, 2014

Recursive CTE Multi-Level Explosion in Exact MAX

 

 

Below is a recursive CTE that does a multi-level explosion for the current effective date.

;with mlBOM

as

(

select  PARPRT_02, COMPRT_02

, QTYPER_02, EFFDTE_02

from Product_Structure

WHERE PARPRT_02 = 'ENTER PARENT PART'

union all -- CTE recursion

select  n.PARPRT_02, n.COMPRT_02

, n.QTYPER_02, N.EFFDTE_02

from Product_Structure n

inner join mlBOM c on c.COMPRT_02 = n.PARPRT_02

)

-- final select aggregating values

-- displays unique PARPRT_02 - COMPRT_02 combinations

select  PARPRT_02, COMPRT_02, QTYPER_02, EFFDTE_02

from mlBOM

WHERE EFFDTE_02 <= GETDATE() OR EFFDTE_02 IS NULL

group by  PARPRT_02, COMPRT_02, QTYPER_02, EFFDTE_02

;

Thursday, February 20, 2014

SQL 2005 Error Message when running DBCC CheckDB - Configuration option 'allow updates' changed from 0 to 0. Run the RECONFIGURE statement to install.

Then get:

 

Msg 5834, Level 16, State 1, Line 1
The affinity mask specified conflicts with the IO affinity mask specified. Use the override option to force this configuration.

 

Use this to fix it:

 

sp_configure 'Allow Updates', 0
RECONFIGURE WITH OVERRIDE