Matrix multiplication without cursors?

  • I could use some design direction here:

    Original design of my db for this client:

    One person has 126 numeric scores from a quiz.

    Each score has a group code and a trait code.

    CREATE TABLE [dbo].[AllScores](

    [ID] [int] IDENTITY(1,1) NOT NULL,

    [RespondentNumber] [int] NOT NULL,

    [AllScoresCollection] [int] NOT NULL,

    [GroupCode] [varchar](3) NOT NULL,

    [Trait] [varchar](2) NOT NULL,

    [Normalized_Score] [float] NULL

    Each analysis group has a varying number of scores to match up to the respondent's scores (e.g. join on groupcode and trait):

    CREATE TABLE [dbo].[KTScores](

    [ID] [int] IDENTITY(1,1) NOT NULL,

    [Key_Trait_Number] [int] NOT NULL,

    [GroupCode] [varchar](3) NOT NULL,

    [Trait] [varchar](2) NOT NULL,

    [TableCode] [smallint] NOT NULL,

    [HighPerfScore] [smallint] NULL,

    [AvgPerfScore] [smallint] NULL,

    [RN] [smallint] NULL,

    [RF] [smallint] NULL

    TableCode is 1, 2 or 3

    Where Table Code is 1, we want the average of all matching scores

    Where TableCode is 2, we want the average of all matching scores rounded up or down to the nearest 5 and have a constant subtracted.

  • Just a few more things are really needed. Sample data for the tables in a readily consumable format, expected results based on that sample data, and the code you currently have atttemped (both cursor-based and set-based).

  • From a second thread so that everything is here:

    PhilM99 (5/1/2009)


    I could use some design direction here:

    Original design of my db for this client:

    One person has 126 numeric scores from a quiz.

    Each score has a group code and a trait code.

    CREATE TABLE [dbo].[AllScores](

    [ID] [int] IDENTITY(1,1) NOT NULL,

    [RespondentNumber] [int] NOT NULL,

    [AllScoresCollection] [int] NOT NULL,

    [GroupCode] [varchar](3) NOT NULL,

    [Trait] [varchar](2) NOT NULL,

    [Normalized_Score] [float] NULL

    Each analysis group has a varying number of scores to match up to the respondent's scores (e.g. join on groupcode and trait):

    CREATE TABLE [dbo].[KTScores](

    [ID] [int] IDENTITY(1,1) NOT NULL,

    [Key_Trait_Number] [int] NOT NULL,

    [GroupCode] [varchar](3) NOT NULL,

    [Trait] [varchar](2) NOT NULL,

    [TableCode] [smallint] NOT NULL,

    [HighPerfScore] [smallint] NULL,

    [AvgPerfScore] [smallint] NULL,

    [RN] [smallint] NULL,

    [RF] [smallint] NULL

    TableCode is 1, 2 or 3

    Where Table Code is 1, we want the average of all matching scores

    Where TableCode is 2, we want the average of all matching scores rounded up or down to the nearest 5 and have a constant subtracted.

    Where TableCode is 3, we want the average of all matching scores rounded up or down to the nearest 5 and have a different constant subtracted.

    In each case for 1,2 and 3, if RF is 1 the answer is to be subtracted from RN.

    The desired result for the respondent is the sum of the three numbers.

    I've had this working for years.. it was designed for one person to be analysed against a few traits. Then they asked for several people to be analysed against several traits.

    I built it using temporary cursors and RBAR analysis. Not the fastest way.

    Now they want large numbers of people (500 or so) to be analysed against hundreds of traits (500x126 scores against up to 33 scores each).

    This is essentailly a huge matrix multiplication problem. I think.

    Where do I start, to design my rewrite? Is this posted in the right place? (I am using SQL 2000, 2005 and plan to use 2008).

  • Looks doable to me. Maybe even in a view. If you can get us the stuff that Lynn asked for, it shouldn't be too hard.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • In the hopes that this won't be overkill, here's the stored proc I use currently.

    Some notes:

    The list of analyses to perform is a list of integers matching the KeyTraitNumber field in table KTScores (parameter @KTToDo) ; the list of scores for the respondents that we have to do is in variable @AllScores. Both of these are comma delimited lists that the stored proc parses back out.

    Question-- In SQL2008, is there a better way,perhaps XML, to pass these in? Or maybe I should create a table which the stored proc can read?

    This proc is capable of doing a detailed analysis ('D') or a summary analysis ('S') and of sorting as required.

    For the prupose of my new design I do not need to do a detailed analysis (summary only), nor do I need to sort. Although, any comments you might have on my primitive ways of doing so might be useful in the future (I am not the best stored proc writer).

    You will note the use of cursors in here. My main question is can I do this work in a set-based fashion?

    In my next post I'll give you some sample data.

    USE [Generator]

    GO

    /****** Object: StoredProcedure [dbo].[GetKTAnalysis_2] Script Date: 05/01/2009 21:18:42 ******/

    SET ANSI_NULLS OFF

    GO

    SET QUOTED_IDENTIFIER OFF

    GO

    ALTER PROC [dbo].[GetKTAnalysis_2]

    @Request varchar(2),

    @KTToDo varchar(max), --overrride for a machine with SQL Server 2000 was 6000

    @AllScores varchar(max), --overrride for a machine with SQL Server 2000 was 3000

    @VER varchar(100) = NULL OUTPUT,

    @Debug bit = 0

    AS

    /***************************************************************************************************************************************************

    * PROCEDURE: GetKTAnalysis_2

    * PURPOSE: Get a recordset back of the KT

    * RETURNS: Recordset

    * NOTES: Same as GetKTAnalysis excel when request is SS returns same summary as SN (1 row per KT)

    * USAGE:

    * CREATED: Amber1\Phil Mahon, http://www.cottagecomputing.com, 2003-05-20

    * MODIFIED

    * DATEAUTHORDESCRIPTION

    *----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    2008-10-22PFMSee overrides above for length of input parameters (for use on development machine, have to change back for live CLA)

    2008-9-23PFMAltered setup so that PFSGen may passs in some collections (KT >= 9000), or 0 meaning do all KTs.

    This permits more KT numbers to be passed in through @KTToDo. This proc, rename to GetKTAnalysis_2, looks up the collection

    members and adds them. Otherwise, the proc is unchanged.

    2004-06-26PFMHad to Clear some variables in last few lines of proc...in summary

    2004-05-21PFMChanged@KTTODO to length 6000

    ******************************************************************************************************************************************/

    SET NOCOUNT ON

    SET @VER = 'GetKTAnalysis_2 1.0 2008-09-23'

    --usage:

    -- PFSGen.KeyTraits.KeyTraits

    --Request:

    --Position 1 - 'S' Means Summary Only

    -- 'D' Means Detail and Summary

    -- 'V' Means Return Version Number and Detail in Second and Version in Return Code

    -- Position 2 (optional)

    -- -'S' Means sorted by predictor score, descending (summary only)

    -- -'N' Means sorted by Name, Ascending, summary only

    --KTToDo: Comma delimited list of key trait numbers that are to be analysed in one pass

    --AllScores; Comma delimited list of the allscores for this respondent. Straight extraction from their allscores,

    -- respondent number, groupcode (3 char), traitnumber (2 char numeric), score (0-100, numeric, usually integer but decimal works)

    -- If the request is for a summary sorted, we are to return only '94' rows, only one row per key trait

    --for sort by score, we sort descing based onthe respondent's score and use only the '94 row as is

    --for sort by name, the purpose is administrative and the rows returned are slightly different

    -- in that we want to capture the disciminator and career fits for the respondent and return them as well,

    -- in the same row, where we would normally have returned the high and average scores.

    -- each row thus has:

    -- 'Respondent Number

    -- KT Num

    --KT Name

    --SubScore

    --Discriminator

    --CareerFit

    --Resp Score

    -- if the sort is by name, we sort by name of key trait, ascending

    -- if the sort is by score, we sort by respondent's predicotr of perfromance score, descending

    --Note that TC means 'Table Code'

    -- TC -- 1 means table of detailed traits scores TC =1, GroupCode= Three digit Group of Individual Trait, GroupDesc = Description of Individual Trait,

    --Trait=Two Digit Trait Number within that Group, TraitDesc=Description of individual trait

    -- 2 means table of discriminating traits TC =2, GroupCode= Three digit Group of Individual Trait, GroupDesc = Description of Individual Trait,

    --Trait=Two Digit Trait Number within that Group, TraitDesc=Description of individual trait

    -- 3 means table of career fit traits TC =3, GroupCode= Three digit Group of Individual Trait, GroupDesc = Description of Individual Trait,

    --Trait=Two Digit Trait Number within that Group, TraitDesc=Description of individual trait

    --91 means summary row of individual scores. TC = 91, GroupCode ='Summary', GroupDesc ='Summary', Trait = '99,

    --TraitDesc = 'Sub-Score'

    --92 means summary row of dscriminators. TC = 92, GroupCode ='Summary', GroupDesc ='Summary', Trait = '99,

    --TraitDesc = 'Discriminator Factor'

    --93 means summary row of individual scores. TC = 93, GroupCode ='Summary', GroupDesc ='Summary', Trait = '99,

    --TraitDesc = 'Career Fit Factor'

    --94 means summary row of individual scores. TC = 94, GroupCode ='Summary', GroupDesc ='Summary', Trait = '99,

    --TraitDesc = 'Predictor of Performance'

    DECLARE @DETSUMM char(1) -- 'D' = Detail with Summary, 'S' = Summary only

    DECLARE @SORTSEQ char(1) -- 'S' - Descending by score, 'N' - Ascending by name, 'K' --Ascending By Key Trait Number

    SET @DETSUMM = LEFT(@Request, 1)

    IF @DETSUMM = 'V'

    BEGIN

    RETURN 0

    END

    SET @SORTSEQ = 'X' --Default to no sorting (we will still sort by respondent, key trait, and trait code

    IF LEN(@Request) = 2 --If a sort is specified, we can only return the '94' rows, predictor of performance

    BEGIN

    SET @DETSUMM = 'S' --override any other setting since we can only specify sort for the summary, and only the 94 row.

    SET @SORTSEQ = RIGHT(@Request, 1)

    END

    DECLARE @TempScores table(

    [RespondentNumber] [int] NOT NULL ,

    [AllScoresCollection] [int] NOT NULL ,

    [GroupCode] [nvarchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

    [Trait] [nvarchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

    [NormalizedScore] int NULL

    )

    DECLARE @KTNums table ([KTN] int)

    DECLARE @KTN int

    --Declare variables and load them for the discriminator max and career fit max from the defaults table

    DECLARE @DDiscMax int

    DECLARE @DCareerMax int

    SELECT @DDiscMax=DDISCMAX, @DCareerMax=DCareerMax FROM DEFAULTS

    If @Debug = 1

    BEGIN

    PRINT 'Maximum Discriminator= ' + Cast(@DDiscMax as varchar(2))

    PRINT 'Maximum Career Fit= ' + Cast(@DCareerMax as varchar(2))

    END

    --BEGIN OUTER

    BEGIN

    SET NOCOUNT ON

    DECLARE @Pos int

    DECLARE @RespondentNumber int, @AllScoresCollection int, @GroupCode nvarchar (3), @Trait nvarchar (2), @NormalizedScore decimal (10,2)

    -- Move AllScores comma delimited string into a table variable so we can join on it

    SET @AllScores = LTRIM(RTRIM(@AllScores))+ ','

    SET @Pos = CHARINDEX(',', @AllScores, 1)

    IF REPLACE(@AllScores, ',', '') ''

    BEGIN

    WHILE @Pos > 0

    BEGIN

    WHILE @Pos > 0

    BEGIN

    SET @RespondentNumber = CAST( LTRIM(RTRIM(LEFT(@AllScores, @Pos - 1))) AS int)

    SET @AllScores = RIGHT(@AllScores, LEN(@AllScores) - @Pos)

    SET @Pos = CHARINDEX(',', @AllScores, 1)

    SET @AllScoresCollection = CAST(LTRIM(RTRIM(LEFT(@AllScores, @Pos - 1))) AS int)

    SET @AllScores = RIGHT(@AllScores, LEN(@AllScores) - @Pos)

    SET @Pos = CHARINDEX(',', @AllScores, 1)

    SET @GroupCode = LTRIM(RTRIM(LEFT(@AllScores, @Pos - 1)))

    SET @AllScores = RIGHT(@AllScores, LEN(@AllScores) - @Pos)

    SET @Pos = CHARINDEX(',', @AllScores, 1)

    SET @Trait = LTRIM(RTRIM(LEFT(@AllScores, @Pos - 1)))

    SET @AllScores = RIGHT(@AllScores, LEN(@AllScores) - @Pos)

    SET @Pos = CHARINDEX(',', @AllScores, 1)

    SET @NormalizedScore = CAST(CAST(LTRIM(RTRIM(LEFT(@AllScores, @Pos - 1))) AS DECIMAL (10,2)) AS int)

    SET @AllScores = RIGHT(@AllScores, LEN(@AllScores) - @Pos)

    SET @Pos = CHARINDEX(',', @AllScores, 1)

    INSERT INTO @TempScores ([RespondentNumber], [AllScoresCollection],[GroupCode], [Trait], [NormalizedScore])

    VALUES (@RespondentNumber, @AllScoresCollection, @GroupCode, @Trait, @NormalizedScore)

    END

    END

    END

    If @Debug = 1

    BEGIN

    SELECT * FROM @TempScores

    END

    --Changes from GetKTanalysis_1

    IF @KTToDo = '0' --This is new from KTAnalysis_1

    BEGIN

    INSERT INTO @KTNums ([KTN])

    SELECT Key_Trait_Number from KTNames -- Put them all in the table

    END

    ELSE

    BEGIN

    --Move Key Trait Numbers to do into a table variable for joining

    SET @KTToDo = LTRIM(RTRIM(@KTToDo))+ ','

    SET @Pos = CHARINDEX(',', @KTToDo, 1)

    IF REPLACE(@KTToDo, ',', '') ''

    BEGIN

    WHILE @Pos > 0

    BEGIN

    WHILE @Pos > 0

    BEGIN

    SET @KTN = CAST( LTRIM(RTRIM(LEFT(@KTToDo, @Pos - 1))) AS int)

    SET @KTToDo = RIGHT(@KTToDo, LEN(@KTToDo) - @Pos)

    SET @Pos = CHARINDEX(',', @KTToDo, 1)

    --Changes from GetKTanalysis_1. Obsoleted code:

    /*

    INSERT INTO @KTNums ([KTN])

    VALUES (@KTN)

    END

    */

    --New Code:

    If @KTN >= 9000 -- Is it really a collection? If so get members

    BEGIN

    INSERT INTO @KTNums ([KTN])

    --Following select copied from proc [GetKTCollectionMembers] which was used in the PFSGen code.

    --Makes more sense to do the lookup in SQL Server

    SELECT KTCollections.Key_Trait_Number

    FROM KTCollectionNames INNER JOIN KTCollections ON (KTCollectionNames.Key_Trait_Collection_Number = KTCollections.Key_Trait_Collection_Number)

    WHERE (((KTCollectionNames.Key_Trait_Collection_Number)=@KTN))

    ORDER BY KTCollectionNames.Key_Trait_Collection_Name

    END

    ELSE

    BEGIN

    INSERT INTO @KTNums ([KTN])

    VALUES (@KTN)

    END

    END

    END

    END

    END

    If @Debug = 1

    BEGIN

    SELECT * FROM @KTNums

    END

    --We always will need the summary query, so build it, and put it in the temp table

    --open the rather complex summary and put it into a cursor so we can put it in a table variable and summarize it with a union

    DECLARE Summary_curs CURSOR FOR (

    -- The dummy columns are there for output positioning

    SELECT A.RespondentNumber, A.Key_Trait_Number, A.Key_Trait_Name,

    '9' + Cast(A.TableCode as varchar) AS TC, 'Summary' AS GC, 'Summary' AS GC2, '99' AS Trait, A.Trait_desc as Trait_Desc,

    --Limit Discriminator and Career Fit them to the system maximums

    (CASE A.TableCode

    When 1 Then A.AvgofRespondentScore --Respondent Score row

    When 2 Then --Discriminator Row

    CASE

    -- if the score for the discriminator is higher than the max, use the max

    WHEN ABS(A.AvgofRespondentScore) > @DDiscMax THEN SIGN(A.AvgofRespondentScore) * @DDiscMax -- show the max absolute value instead

    ELSE A.AvgofRespondentScore

    END

    When 3 Then --Career Fit

    CASE

    WHEN ABS(A.AvgofRespondentScore) > @DCareerMax THEN SIGN(A.AvgofRespondentScore) * @DCareerMax -- show the max absolute value instead

    ELSE A.AvgofRespondentScore

    END

    END

    )

    AS AvgofRespondentScore,

    (CASE A.TableCode

    When 1 Then A.AvgOfHighPerfScore

    When 2 Then --Discriminator Row

    CASE

    WHEN ABS(A.AvgOfHighPerfScore) > @DDiscMax THEN SIGN(A.AvgOfHighPerfScore) * @DDiscMax -- show the max absolute value instead

    ELSE A.AvgOfHighPerfScore

    END

    When 3 Then --Career Fit

    CASE

    WHEN ABS(A.AvgOfHighPerfScore) > @DCareerMax THEN SIGN(A.AvgOfHighPerfScore) * @DCareerMax -- show the max absolute value instead

    ELSE A.AvgOfHighPerfScore

    END

    END

    )

    AS AvgOfHighPerfScore,

    (CASE A.TableCode

    When 1 Then A.AvgOfAvgPerfScore

    When 2 Then --Discriminator Row

    CASE

    WHEN ABS(A.AvgOfAvgPerfScore) > @DDiscMax THEN SIGN(A.AvgOfAvgPerfScore) * @DDiscMax -- show the max absolute value instead

    ELSE A.AvgOfAvgPerfScore

    END

    When 3 Then --Career Fit

    CASE

    WHEN ABS(A.AvgOfAvgPerfScore) > @DCareerMax THEN SIGN(A.AvgOfAvgPerfScore) * @DCareerMax -- show the max absolute value instead

    ELSE A.AvgOfAvgPerfScore

    END

    END

    )

    AS AvgOfAvgPerfScore,

    Key_Trait_Report_Name, DiscConstant, CareerConstant, 'Summary' AS Nada

    FROM (

    SELECT TS.RespondentNumber, KTScores.Key_Trait_Number, KTNames.Key_Trait_Name, KTScores.TableCode,

    CASE KTScores.TableCode

    WHEN 1 THEN 'Sub-Score'

    WHEN 2 THEN 'Discriminator Factor'

    WHEN 3 THEN 'Career Fit Factor'

    ELSE 'Invalid Table Code'

    END AS Trait_Desc ,

    -- Respondent Column

    CASE KTScores.TableCode

    WHEN 1 THEN

    --Our Respondent has their score rounded up, only

    ROUND(Avg(

    CASE KTScores.RF

    --have to CAST scores as numeric to get the fraction to round up

    WHEN 1 THEN CAST(NormalizedScore as numeric)

    ELSE CAST([RN]-[NormalizedScore] as numeric)

    END),0)

    WHEN 2 THEN

    -- All Discriminator factors get reduced by the discriminator constant

    ROUND(Avg(

    CASE KTScores.RF

    WHEN 1 THEN CAST(NormalizedScore as numeric)

    ELSE CAST([RN]-[NormalizedScore] as numeric)

    END),0) - DiscConstant

    WHEN 3 THEN

    -- All CareerFit factors get reduced by the career fit constant

    ROUND(Avg(

    CASE KTScores.RF

    WHEN 1 THEN CAST(NormalizedScore as numeric)

    ELSE CAST([RN]-[NormalizedScore] as numeric)

    END),0) - CareerConstant

    END AS AvgofRespondentScore,

    -- High Performer Column

    CASE KTScores.TableCode

    WHEN 1 THEN

    --The high performer has the score rounded up or down to the nearest multiple of 5

    (5* (ROUND((ROUND((((2 *

    Avg(

    CASE KTScores.RF

    WHEN 1 THEN KTScores.HighPerfScore

    ELSE RN-KTScores.HighPerfScore

    END)) + 5)),0,1) / 10),0,1)))

    WHEN 2 THEN

    -- All Discriminator factors get reduced by the discriminator constant

    (5* (ROUND((ROUND((((2 *

    Avg(

    CASE KTScores.RF

    WHEN 1 THEN KTScores.HighPerfScore

    ELSE RN-KTScores.HighPerfScore

    END)) + 5)),0,1) / 10),0,1))) - DiscConstant

    WHEN 3 THEN

    -- All CareerFit factors get reduced by the career fit constant

    (5* (ROUND((ROUND((((2 *

    Avg(

    CASE KTScores.RF

    WHEN 1 THEN KTScores.HighPerfScore

    ELSE RN-KTScores.HighPerfScore

    END)) + 5)),0,1) / 10),0,1))) - CareerConstant

    ENDAS AvgOfHighPerfScore,

    -- Average Performer Column

    CASE KTScores.TableCode

    WHEN 1 THEN

    --The average performer has the score rounded up or down to the nearest multiple of 5

    (5* (ROUND((ROUND((((2 *

    Avg(

    CASE KTScores.RF

    WHEN 1 THEN AvgPerfScore

    ELSE RN-KTScores.AvgPerfScore

    END)) + 5)),0,1) / 10),0,1)))

    WHEN 2 THEN

    -- All Discriminator factors get reduced by the discriminator constant

    (5* (ROUND((ROUND((((2 *

    Avg(

    CASE KTScores.RF

    WHEN 1 THEN AvgPerfScore

    ELSE RN-KTScores.AvgPerfScore

    END)) + 5)),0,1) / 10),0,1))) - DiscConstant

    WHEN 3 THEN

    -- All CareerFit factors get reduced by the career fit constant

    (5* (ROUND((ROUND((((2 *

    Avg(

    CASE KTScores.RF

    WHEN 1 THEN AvgPerfScore

    ELSE RN-KTScores.AvgPerfScore

    END)) + 5)),0,1) / 10),0,1))) - CareerConstant

    END AS AvgOfAvgPerfScore,

    KTNames.Key_Trait_Report_Name, KTNames.DiscConstant, KTNames.CareerConstant

    FROM ((KTScores INNER JOIN @TempScores TS ON (KTScores.Trait = TS.Trait) AND (KTScores.GroupCode = TS.GroupCode)) INNER JOIN KTNames ON KTScores.Key_Trait_Number = KTNames.Key_Trait_Number) INNER JOIN @KTNums B ON KTScores.Key_Trait_Number= B.KTN

    GROUP BY

    TS.RespondentNumber, KTScores.Key_Trait_Number, KTNames.Key_Trait_Name, KTScores.TableCode,

    CASE KTScores.TableCode

    WHEN 1 THEN 'Sub-Score'

    WHEN 2 THEN 'Discriminator Factor'

    WHEN 3 THEN 'Career Fit Factor'

    ELSE 'Invalid Table Code'

    END,

    KTNames.Key_Trait_Report_Name, KTNames.DiscConstant, KTNames.CareerConstant

    ) AS A

    ) --end of DECLARE Summary_Curs

    --need some variables to hold the cursor variables

    DECLARE @XRespondentNumber int

    DECLARE @XKey_Trait_Number int

    DECLARE @XKey_Trait_Name nvarchar (100)

    DECLARE @XTC nvarchar (2)

    DECLARE @XGC nvarchar (2)

    DECLARE @XGC2 nvarchar (2)

    DECLARE @XTrait nvarchar (2)

    DECLARE @XTrait_Desc nvarchar (200)

    DECLARE @XAvgofRespondentScore int

    DECLARE @XAvgOfHighPerfScore int

    DECLARE @XAvgOfAvgPerfScore int

    DECLARE @XKey_Trait_Report_Name nvarchar (200)

    DECLARE @XDiscConstant int

    DECLARE @XCareerConstant int

    DECLARE @XNada nvarchar (20)

    DECLARE @TempSummary table(

    [RespondentNumber] [int] NOT NULL ,

    [Key_Trait_Number] [int] NOT NULL ,

    [Key_Trait_Name] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

    [TC] [nvarchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

    [GC] [nvarchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

    [GC2] [nvarchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

    [Trait] [nvarchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

    [Trait_Desc] [nvarchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

    [AvgofRespondentScore] int NULL,

    [AvgOfHighPerfScore] int NULL,

    [AvgOfAvgPerfScore] int NULL,

    [Key_Trait_Report_Name] [nvarchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

    [DiscConstant] int NULL,

    [CareerConstant] int NULL,

    [Nada] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL

    )

    OPEN Summary_Curs

    FETCH NEXT FROM Summary_Curs INTO

    @XRespondentNumber,

    @XKey_Trait_Number,

    @XKey_Trait_Name,

    @XTC,

    @XGC,

    @XGC2,

    @XTrait,

    @XTrait_Desc,

    @XAvgofRespondentScore,

    @XAvgOfHighPerfScore,

    @XAvgOfAvgPerfScore,

    @XKey_Trait_Report_Name,

    @XDiscConstant,

    @XCareerConstant,

    @XNada

    WHILE @@FETCH_STATUS = 0

    BEGIN

    INSERT INTO @TempSummary (

    [RespondentNumber],

    [Key_Trait_Number],

    [Key_Trait_Name],

    [TC],

    [GC],

    [GC2],

    [Trait],

    [Trait_Desc],

    [AvgofRespondentScore],

    [AvgOfHighPerfScore],

    [AvgOfAvgPerfScore],

    [Key_Trait_Report_Name],

    [DiscConstant],

    [CareerConstant],

    [Nada])

    VALUES(

    @XRespondentNumber,

    @XKey_Trait_Number,

    @XKey_Trait_Name,

    @XTC,

    @XGC,

    @XGC2,

    @XTrait,

    @XTrait_Desc,

    @XAvgofRespondentScore,

    @XAvgOfHighPerfScore,

    @XAvgOfAvgPerfScore,

    @XKey_Trait_Report_Name,

    @XDiscConstant,

    @XCareerConstant,

    @XNada)

    FETCH NEXT FROM Summary_Curs INTO

    @XRespondentNumber,

    @XKey_Trait_Number,

    @XKey_Trait_Name,

    @XTC,

    @XGC,

    @XGC2,

    @XTrait,

    @XTrait_Desc,

    @XAvgofRespondentScore,

    @XAvgOfHighPerfScore,

    @XAvgOfAvgPerfScore,

    @XKey_Trait_Report_Name,

    @XDiscConstant,

    @XCareerConstant,

    @XNada

    END

    CLOSE Summary_Curs

    DEALLOCATE Summary_Curs

    --now the temp table is loaded with the summary we can use it and reuse it

    If @Debug = 1

    BEGIN

    SELECT * FROM @TempSummary

    END

    /*

    Const lRn As Long = 0 'Respondent Number

    Const lKT As Long = 1 'Key trait Number

    Const lKTN As Long = 2 'Key Trait Name

    Const lTC As Long = 3 'Table Code

    Const lGC As Long = 4 'Group Code

    Const lGN As Long = 5 'Group Name

    Const lTN As Long = 6 'Trait Number

    Const lTD As Long = 7 'Trait Description

    Const lRS As Long = 8 'Respondent Score

    Const lHi As Long = 9 'Hi performer column

    Const lAv As Long = 10 'Avg performer column

    Const lKP As Long = 11 'Key Trait report Name

    Const lDC As Long = 12 'Discriminator Constant

    Const lCF As Long = 13 'Career Fit Constant

    */

    --Now the summary query is available to us

    --If a detailed query is requested, it is always joined to the summary query.

    IF @DETSUMM = 'D'

    BEGIN

    (SELECT TS.RespondentNumber, KTScores.Key_Trait_Number, KTNames.Key_Trait_Name, KTScores.TableCode, KTScores.GroupCode, Groups.GroupDesc,

    KTScores.Trait, Traits.TraitDesc,

    -- Respondent Column

    CASE KTScores.TableCode

    WHEN 1 THEN

    CASE KTScores.RF

    WHEN 1 THEN NormalizedScore

    ELSE [RN]-[NormalizedScore]

    END

    WHEN 2 THEN

    CASE KTScores.RF

    WHEN 1 THEN NormalizedScore

    ELSE [RN]-[NormalizedScore]

    END

    WHEN 3 THEN

    CASE KTScores.RF

    WHEN 1 THEN NormalizedScore

    ELSE [RN]-[NormalizedScore]

    END

    END AS RespondentScore,

    -- High Performer Column

    CASE KTScores.TableCode

    WHEN 1 THEN

    CASE KTScores.RF

    WHEN 1 THEN KTScores.HighPerfScore

    ELSE RN-KTScores.HighPerfScore

    END

    WHEN 2 THEN

    CASE KTScores.RF

    WHEN 1 THEN KTScores.HighPerfScore

    ELSE RN-KTScores.HighPerfScore

    END

    WHEN 3 THEN

    CASE KTScores.RF

    WHEN 1 THEN KTScores.HighPerfScore

    ELSE RN-KTScores.HighPerfScore

    END

    ENDAS HighPerfScore,

    -- Average Performer Column

    CASE KTScores.TableCode

    WHEN 1 THEN

    CASE KTScores.RF

    WHEN 1 THEN AvgPerfScore

    ELSE RN-KTScores.AvgPerfScore

    END

    WHEN 2 THEN

    CASE KTScores.RF

    WHEN 1 THEN AvgPerfScore

    ELSE RN-KTScores.AvgPerfScore

    END

    WHEN 3 THEN

    CASE KTScores.RF

    WHEN 1 THEN AvgPerfScore

    ELSE RN-KTScores.AvgPerfScore

    END

    END AS AvgPerfScore,

    KTNames.Key_Trait_Report_Name, KTNames.DiscConstant, KTNames.CareerConstant, Traits.BriefDescription

    FROM (((KTScores INNER JOIN @TempScores TS ON (KTScores.Trait = TS.Trait) AND (KTScores.GroupCode = TS.GroupCode)INNER JOIN GROUPS ON(TS.AllScoresCollection = Groups.AllScoresCollection AND TS.GroupCode = Groups.GroupCode)INNER JOIN TRAITS ON(TS.AllScoresCollection = TRAITS.AllScoresCollection AND TS.GroupCode = TRAITS.GroupCode AND TS.Trait = TRAITS.Trait) )

    INNER JOIN KTNames ON KTScores.Key_Trait_Number = KTNames.Key_Trait_Number)

    INNER JOIN @KTNums B ON KTScores.Key_Trait_Number= B.KTN)

    )

    --end detailed

    --begin to get the summary to union to the detailed

    UNION ALL

    -- Retrieve the summary rows

    -- The dummy columns are there for output positioning

    (SELECT A.RespondentNumber, A.Key_Trait_Number, A.Key_Trait_Name,

    A.TC, 'Summary' AS GC, 'Summary' AS GC2, '99' AS Trait, A.Trait_desc as Trait_Desc,

    A.AvgofRespondentScore AS AvgofRespondentScore,

    A.AvgOfHighPerfScore AS AvgOfHighPerfScore,

    A.AvgOfAvgPerfScore AS AvgOfAvgPerfScore,

    Key_Trait_Report_Name, DiscConstant, CareerConstant, 'Summary' AS Nada

    FROM @TempSummary AS A

    UNION ALL

    -- The dummy columns are there for output positioning

    SELECT A.RespondentNumber, A.Key_Trait_Number, A.Key_Trait_Name,

    '94' AS TC, 'Summary' AS GC, 'Summary' AS GC2, '99' AS Trait, 'Predictor of Performance' as Trait_Desc,

    A.AvgofRespondentScore AS AvgofRespondentScore,

    A.AvgOfHighPerfScore AS AvgOfHighPerfScore,

    A.AvgOfAvgPerfScore AS AvgOfAvgPerfScore,

    Key_Trait_Report_Name, DiscConstant, CareerConstant, 'Summary' AS Nada

    FROM (

    SELECT

    [RespondentNumber],

    [Key_Trait_Number],

    [Key_Trait_Name],

    [GC],

    [GC2],

    Sum([AvgofRespondentScore]) AS AvgofRespondentScore,

    Sum([AvgOfHighPerfScore]) AS AvgOfHighPerfScore,

    Sum([AvgOfAvgPerfScore]) AS AvgOfAvgPerfScore,

    [Key_Trait_Report_Name],

    [DiscConstant],

    [CareerConstant],

    [Nada]

    FROM @TempSummary

    GROUP BY

    [RespondentNumber],

    [Key_Trait_Number],

    [Key_Trait_Name],

    [GC],

    [GC2],

    [Key_Trait_Report_Name],

    [DiscConstant],

    [CareerConstant],

    [Nada]) AS A)

    ORDER BY TS.RespondentNumber, KTScores.Key_Trait_Number, KTScores.TableCode, RespondentScore DESC, HighPerfScore DESC, AvgPerfScore DESC

    END -- End of IF @DETSUMM = 'D'

    ELSE

    -- This is where we are ONLY doing a summary

    BEGIN --only a summary

    IF @SORTSEQ ='X' -- Unsorted goes here 'N' AND @SORTSEQ 'S' AND @SORTSEQ 'K' --2008-5-31 ALL types. --2006-10-27 Let both types of sort drop through to the ELSE

    BEGIN

    -- Retrieve the summary rows

    SELECT * FROM

    -- The dummy columns are there for output positioning

    (SELECT A.RespondentNumber, A.Key_Trait_Number, A.Key_Trait_Name,

    A.TC, 'Summary' AS GC, 'Summary' AS GC2, '99' AS Trait, A.Trait_desc as Trait_Desc,

    A.AvgofRespondentScore AS AvgofRespondentScore,

    A.AvgOfHighPerfScore AS AvgOfHighPerfScore,

    A.AvgOfAvgPerfScore AS AvgOfAvgPerfScore,

    Key_Trait_Report_Name, DiscConstant, CareerConstant, 'Summary' AS Nada

    FROM @TempSummary A

    UNION ALL

    -- The dummy columns are there for output positioning

    SELECT A.RespondentNumber, A.Key_Trait_Number, A.Key_Trait_Name,

    '94' AS TC, 'Summary' AS GC, 'Summary' AS GC2, '99' AS Trait, 'Predictor of Performance' as Trait_Desc,

    A.AvgofRespondentScore AS AvgofRespondentScore,

    A.AvgOfHighPerfScore AS AvgOfHighPerfScore,

    A.AvgOfAvgPerfScore AS AvgOfAvgPerfScore,

    Key_Trait_Report_Name, DiscConstant, CareerConstant, 'Summary' AS Nada

    FROM (

    SELECT

    [RespondentNumber],

    [Key_Trait_Number],

    [Key_Trait_Name],

    [GC],

    [GC2],

    Sum([AvgofRespondentScore]) AS AvgofRespondentScore,

    Sum([AvgOfHighPerfScore]) AS AvgOfHighPerfScore,

    Sum([AvgOfAvgPerfScore]) AS AvgOfAvgPerfScore,

    [Key_Trait_Report_Name],

    [DiscConstant],

    [CareerConstant],

    [Nada]

    FROM @TempSummary

    GROUP BY

    [RespondentNumber],

    [Key_Trait_Number],

    [Key_Trait_Name],

    [GC],

    [GC2],

    [Key_Trait_Report_Name],

    [DiscConstant],

    [CareerConstant],

    [Nada]) AS A)

    AS B

    WHERE (@SORTSEQ = 'X') OR (@SORTSEQ 'X' AND TC ='94') -- If the request is for sorting we can only include summary line 94

    ORDER BY

    B.RespondentNumber, --always sort by this one first

    CASE @SORTSEQ

    WHEN 'X' THEN CAST(B.Key_Trait_Number as varchar(15)) --When no sort sequence is requested, sort by Trait Number and Table Code

    WHEN 'N' THEN B.Key_Trait_Name --Sort by Name

    WHEN 'S' THEN B.Trait --essentially this column does not sort since all traits are 99 included for readability

    ELSE B.Trait --essentially this column does not sort since all traits are 99

    END, --end of case

    CASE @SORTSEQ

    WHEN 'X' THEN B.Trait --essentially this column does not sort since all traits are 99 included for readability

    WHEN 'N' THEN B.Trait --essentially this column does not sort since all traits are 99 included for readability

    WHEN 'S' THEN B.AvgofRespondentScore -- S means sort by respondent score desc

    ELSE B.Trait --essentially this column does not sort since all traits are 99

    END DESC, --end of case

    CASE

    WHEN @SORTSEQ = 'X' THEN B.TC --When no sort sequence is requested, sort by Trait Number and Table Code

    ELSE B.Trait --essentially this column does not sort since all traits are 99

    END --end of case

    END --end of true part

    ELSE

    BEGIN

    --if sortseq is 'N' or 'S' or 'K', this is a special case.

    -- we have to combine the 91, 92, 93, 94 row into a 'special' 94 row.

    --To do this put all the summary rows into a cursor and whip through it

    -- Retrieve the summary rows

    DECLARE TempSumm_curs CURSOR FOR (

    SELECT RespondentNumber, Key_Trait_Number, Key_Trait_Name, TC, AvgofRespondentScore FROM (

    SELECT TOP 400000 * FROM --was 3000

    -- The dummy columns are there for output positioning

    (SELECT A.RespondentNumber, A.Key_Trait_Number, A.Key_Trait_Name,

    A.TC, 'Summary' AS GC, 'Summary' AS GC2, '99' AS Trait, A.Trait_desc as Trait_Desc,

    A.AvgofRespondentScore AS AvgofRespondentScore,

    A.AvgOfHighPerfScore AS AvgOfHighPerfScore,

    A.AvgOfAvgPerfScore AS AvgOfAvgPerfScore,

    Key_Trait_Report_Name, DiscConstant, CareerConstant, 'Summary' AS Nada

    FROM @TempSummary A

    UNION ALL

    -- The dummy columns are there for output positioning

    SELECT A.RespondentNumber, A.Key_Trait_Number, A.Key_Trait_Name,

    '94' AS TC, 'Summary' AS GC, 'Summary' AS GC2, '99' AS Trait, 'Predictor of Performance' as Trait_Desc,

    A.AvgofRespondentScore AS AvgofRespondentScore,

    A.AvgOfHighPerfScore AS AvgOfHighPerfScore,

    A.AvgOfAvgPerfScore AS AvgOfAvgPerfScore,

    Key_Trait_Report_Name, DiscConstant, CareerConstant, 'Summary' AS Nada

    FROM (

    SELECT

    [RespondentNumber],

    [Key_Trait_Number],

    [Key_Trait_Name],

    [GC],

    [GC2],

    Sum([AvgofRespondentScore]) AS AvgofRespondentScore,

    Sum([AvgOfHighPerfScore]) AS AvgOfHighPerfScore,

    Sum([AvgOfAvgPerfScore]) AS AvgOfAvgPerfScore,

    [Key_Trait_Report_Name],

    [DiscConstant],

    [CareerConstant],

    [Nada]

    FROM @TempSummary

    GROUP BY

    [RespondentNumber],

    [Key_Trait_Number],

    [Key_Trait_Name],

    [GC],

    [GC2],

    [Key_Trait_Report_Name],

    [DiscConstant],

    [CareerConstant],

    [Nada]) AS A)

    AS B

    --WHERE (@SORTSEQ = 'X') OR (@SORTSEQ 'X' AND TC ='94') -- If the request is for sorting we can only include summary line 94

    ORDER BY

    B.RespondentNumber, --always sort by this one first

    B.Key_Trait_Number,

    B.TC

    ) AS XY

    )-- End of Declare cursor

    --need some variables to hold the cursor variables

    DECLARE @YRespondentNumber int

    DECLARE @YKey_Trait_Number int

    DECLARE @YKey_Trait_Name nvarchar (100)

    DECLARE @YTC nvarchar (2)

    DECLARE @YInputScore int

    DECLARE @YSubscore int

    DECLARE @YDiscriminator int

    DECLARE @YCareerFit int

    DECLARE @YRespScore int

    -- each row thus has:

    -- 'Respondent Number

    -- KT Num

    --KT Name

    --SubScore

    --Discriminator

    --CareerFit

    --Resp Score

    DECLARE @YTempSummary table (

    [RespondentNumber] [int] NOT NULL,

    [Key_Trait_Number] [int] NOT NULL ,

    [Key_Trait_Name] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,

    [SubScore] int NULL,

    [Discriminator] int NULL,

    [CareerFit] int NULL,

    [Predictor] int NULL) --Changed last field name to match what it really is

    DECLARE @SVRespondentNumber int

    DECLARE @SVKey_Trait_Number int

    OPEN TempSumm_curs

    FETCH NEXT FROM TempSumm_curs INTO

    @YRespondentNumber, @YKey_Trait_Number, @YKey_Trait_Name, @YTC, @YInputScore

    SET @SVRespondentNumber = @YRespondentNumber

    SET @SVKey_Trait_Number = @YKey_Trait_Number

    --Reset variables 2004-06-26

    SET @YSubscore = NULL

    SET @YDiscriminator = NULL

    SET @YCareerFit = NULL

    WHILE @@FETCH_STATUS = 0

    BEGIN

    IF @SVRespondentNumber = @YRespondentNumber AND @SVKey_Trait_Number = @YKey_Trait_Number

    BEGIN

    IF @YTC = '91' SET @YSubscore = @YInputScore

    IF @YTC = '92' SET @YDiscriminator = @YInputScore

    IF @YTC = '93' SET @YCareerFit = @YInputScore

    IF @YTC = '94'

    BEGIN

    SET @YRespScore = @YInputScore

    INSERT INTO @YTempSummary(RespondentNumber, Key_Trait_Number, Key_Trait_Name, SubScore, Discriminator, CareerFit, Predictor)

    VALUES(@YRespondentNumber, @YKey_Trait_Number, @YKey_Trait_Name, @YSubscore, @YDiscriminator, @YCareerFit, @YRespScore)

    END

    END

    FETCH NEXT FROM TempSumm_curs INTO

    @YRespondentNumber, @YKey_Trait_Number, @YKey_Trait_Name, @YTC, @YInputScore

    --2004-06-26

    IF @SVRespondentNumber @YRespondentNumber OR @SVKey_Trait_Number @YKey_Trait_Number --Reset variables

    BEGIN

    SET @YSubscore = NULL

    SET @YDiscriminator = NULL

    SET @YCareerFit = NULL

    END

    SET @SVRespondentNumber = @YRespondentNumber

    SET @SVKey_Trait_Number = @YKey_Trait_Number

    END

    CLOSE TempSumm_curs

    DEALLOCATE TempSumm_curs

    IF @SORTSEQ = 'N' --sorting by Name?

    BEGIN

    SELECT * FROM @YTempSummary ORDER BY Key_Trait_Name

    END

    ELSE

    BEGIN

    IF @SORTSEQ = 'K' -- sorting by KT Number (admins do this manually)

    BEGIN

    SELECT * FROM @YTempSummary ORDER BY Key_Trait_Number

    END

    ELSE

    BEGIN

    SELECT * FROM @YTempSummary ORDER BY Predictor DESC

    END

    END

    END -- end of IF @SORTSEQ 'N' AND @SORTSEQ 'S'(false part)

    END --end of summary only

    END--END OUTER

  • Hints on how to extract some data into, perhaps, an INSERT statement, so that it is useful to those trying to help me??

    This is some data for table KTScores (for KT#5 and KT#38)

    I'll wait for some hints before posting some data for the people.. (unless this is a useful format)

    5,HRL,01,1,70,55,0,1

    5,MVF,01,1,70,50,0,1

    5,PSS,01,1,70,60,0,1

    5,SAS,01,1,70,50,0,1

    5,VCI,01,1,70,55,0,1

    5,BUS,01,3,65,60,0,1

    5,MVF,02,1,70,60,0,1

    5,VCI,02,1,70,55,0,1

    5,MVF,03,1,70,50,0,1

    5,SAS,03,1,70,60,0,1

    5,MVF,04,1,65,60,0,1

    5,WKH,04,1,70,60,0,1

    5,BUS,04,3,65,60,0,1

    5,LFS,05,1,70,50,0,1

    5,WKH,05,1,70,55,0,1

    5,BUS,06,3,65,60,0,1

    5,SAS,07,1,70,55,0,1

    5,SVC,07,3,65,60,0,1

    5,CPS,08,1,65,60,0,1

    5,LFS,08,1,70,50,0,1

    5,MVF,08,1,65,55,0,1

    5,WKH,08,1,65,50,0,1

    5,HRL,09,1,65,50,0,1

    5,MVF,09,1,70,55,0,1

    38,PPL,00,3,65,55,0,1

    38,PPL,01,3,65,55,0,1

    38,HRL,02,1,60,50,0,1

    38,HRL,03,1,60,55,0,1

    38,LFS,03,1,65,55,0,1

    38,PSS,03,1,65,55,0,1

    38,VCI,03,1,60,50,0,1

    38,SVC,03,3,65,55,0,1

    38,HRL,04,1,65,55,0,1

    38,MVF,04,1,65,60,0,1

    38,PSS,04,1,60,50,0,1

    38,WKH,04,1,65,55,0,1

    38,WKH,04,2,65,55,0,1

    38,HRL,05,1,60,55,0,1

    38,SAS,05,1,65,60,0,1

    38,VCI,05,1,65,55,0,1

    38,VCI,05,2,65,55,0,1

    38,VCI,06,1,65,60,0,1

    38,PPL,06,3,65,55,0,1

    38,LFS,07,1,65,55,0,1

    38,PSS,07,1,75,65,0,1

    38,LFS,07,2,65,55,0,1

    38,PSS,07,2,65,55,0,1

    38,LFS,08,1,65,55,0,1

    38,PSS,08,1,65,55,0,1

    38,PSS,08,2,65,55,0,1

    38,VCI,09,1,65,60,0,1

    38,WKH,09,1,65,60,0,1

    38,PSS,10,1,60,55,0,1

    5,SAS,01,2,70,50,0,1

    5,WKH,08,2,65,50,0,1

    5,LFS,05,2,70,50,0,1

    5,LFS,08,2,70,50,0,1

    5,MVF,09,2,70,55,0,1

  • Please read the first article referenced in my signature block below.

  • If there's another thread with more detailed information, why the hell are we trying to answer anything on this thread? We're just spitting resources here.;-)

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (5/2/2009)


    If there's another thread with more detailed information, why the hell are we trying to answer anything on this thread? We're just spitting resources here.;-)

    A) I started responding in this thread.

    B) I moved(copied) the more detailed info to this thread, so it is all here now, so might as well use it.

    C) I also pointed the other thread to this thread.

    Okay, three reasons why.

  • Lynn Pettis (5/3/2009)


    Jeff Moden (5/2/2009)


    If there's another thread with more detailed information, why the hell are we trying to answer anything on this thread? We're just spitting resources here.;-)

    A) I started responding in this thread.

    B) I moved(copied) the more detailed info to this thread, so it is all here now, so might as well use it.

    C) I also pointed the other thread to this thread.

    Okay, three reasons why.

    Your choice suprises me, but whatever. Item C being accomplished is the most important. That would have been a good piece of previous information.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I admit that I was a little confused at first also. But then I thought "well, Lynn wouldn't do (b) without also doing (c), so I guess I can just assume it." 🙂

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Yep... that an the fact the I shouldn't go near the forum when I'm having a really bad day. I feel better now... went out a chopped down an Oak tree with nothing more than a couple of sharpened pork chop bones. My arms are a little tired but I feel much better now. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • It's hard to remember you started out to drain the swamp when you're up to your *** in alligators. --old IT saying

    Sorry if I have offended the volunteers here, I was trying to carefully craft my issue in a way that would get me some much needed help. Imagine my surprise when I posted the first item and when the screen finally refreshed, there were two threads there, one with my half finished item!! I immediately tried to delete the entire first thread, to which Lynn had already responded, and the function replies that it is successfully sending email (rather than deleting the thread). Couldn't beat it. It's probably still there.

    And, there's some script running on this forum page that IE objects to and constantly ask me if I want to stop running it. Argh!

    Anyhow, I was going to try to post some data and expected results. Shall I do that, or slink off close to the floor with my tail between my legs?

  • PhilM99 (5/4/2009)


    It's hard to remember you started out to drain the swamp when you're up to your *** in alligators. --old IT saying

    Sorry if I have offended the volunteers here, I was trying to carefully craft my issue in a way that would get me some much needed help. Imagine my surprise when I posted the first item and when the screen finally refreshed, there were two threads there, one with my half finished item!! I immediately tried to delete the entire first thread, to which Lynn had already responded, and the function replies that it is successfully sending email (rather than deleting the thread). Couldn't beat it. It's probably still there.

    And, there's some script running on this forum page that IE objects to and constantly ask me if I want to stop running it. Argh!

    Anyhow, I was going to try to post some data and expected results. Shall I do that, or slink off close to the floor with my tail between my legs?

    Don't worry about it, we're past that now. And yes, please post the data and expected results.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • RBarryYoung (5/4/2009)


    PhilM99 (5/4/2009)


    It's hard to remember you started out to drain the swamp when you're up to your *** in alligators. --old IT saying

    Sorry if I have offended the volunteers here, I was trying to carefully craft my issue in a way that would get me some much needed help. Imagine my surprise when I posted the first item and when the screen finally refreshed, there were two threads there, one with my half finished item!! I immediately tried to delete the entire first thread, to which Lynn had already responded, and the function replies that it is successfully sending email (rather than deleting the thread). Couldn't beat it. It's probably still there.

    And, there's some script running on this forum page that IE objects to and constantly ask me if I want to stop running it. Argh!

    Anyhow, I was going to try to post some data and expected results. Shall I do that, or slink off close to the floor with my tail between my legs?

    Don't worry about it, we're past that now. And yes, please post the data and expected results.

    Yes, I agree, please post the data and expected results.

Viewing 15 posts - 1 through 15 (of 40 total)

You must be logged in to reply to this topic. Login to reply