Forum Replies Created

Viewing 15 posts - 481 through 495 (of 1,439 total)

  • RE: Best way to effienctly store hugh amounts of data

    Sean Lange (9/28/2012)


    What you are describing is what is known as EAV (Entity Value Attribute). This is a horrible design in almost every sense of the word. There are a...

  • RE: Group by column A but compare column B

    Another one

    WITH GrpCounts(ComputerName, ApplicationName,GrpCnt) AS (

    SELECT ComputerName, ApplicationName,

    COUNT(*) OVER(PARTITION BY ComputerName)

    FROM #MyTable),

    Results(ComputerNameA,ComputerNameB) AS (

    SELECT x.ComputerName , y.ComputerName

    FROM GrpCounts x

    INNER JOIN GrpCounts y...

  • RE: Is ok to kill process with security id 0x01 ??

    anthony.green (9/27/2012)


    If the SPID is <= 50 then no dont kill it,

    In my experience, Service Broker internally activated sessions are often on SPIDs less than 50

  • RE: TSQL Suggestion: Support GROUP_CONCAT

    The query can be made to handle XML special characters by doing this

    SELECT t.id,

    STUFF(

    (

    ...

  • RE: Consolidate Overlapping Date Periods

    Here's a snappy query for you

    WITH StartsAndEnds(StartEnd,StartDate,EndDate,HotelId,RoomTypeId) AS (

    SELECT 'S' AS StartEnd,

    StartDate,

    DATEADD(day,-1,StartDate),

    ...

  • RE: extracting individual nodes of XML

    Use the 'nodes' function

    DECLARE @t TABLE(xml_data XML)

    INSERT INTO @t(xml_data) VALUES('

    <Booking Reference= "1111111" Created ="2012-09-24">

    <Hotel Name="Villa Bella">

    </Hotel>

    <Hotel Name="Sea View">

    </Hotel>

    </Booking>')

    SELECT n1.value('@Reference','VARCHAR(10)') AS BReference,

    n1.value('@Created','DATE') AS DateCreated,

    ...

  • RE: Multiple columns IN support

    SELECT ID, NAME

    FROM EMP_TBL

    INTERSECT

    (SELECT '1','foo1'

    UNION ALL

    SELECT '2','foo2')

  • RE: Restart runningtotal when predetermined value is reached

    matak (9/26/2012)


    I will try and explain a little better. Im trying to mark each row based on having a something_runtot up to or equal to 25 - it cant...

  • RE: string operation

    Luis Cazares (9/25/2012)


    I made a different adjustment and seems easier to read (at least for me :-D)

    SELECT SUBSTRING(@s,t2.number,t1.number)

    FROM master.dbo.spt_values t1

    INNER JOIN master.dbo.spt_values t2 ON t2.type='P' AND t2.number BETWEEN 1 AND...

  • RE: string operation

    Use a numbers table

    DECLARE @s-2 VARCHAR(10)

    SET @s-2 = 'tapsaw1'

    SELECT SUBSTRING(@s,t2.number,t1.number)

    FROM master.dbo.spt_values t1

    INNER JOIN master.dbo.spt_values t2 ON t2.type='P' AND t2.number BETWEEN 1 AND LEN(@s) - t1.number + 1

    WHERE t1.type='P' AND t1.number...

  • RE: Addition Of Digits

    Just for fun...

    Using a lookup table improves performance, a bit suprising (for me at least).

    // Pre-calculated sums of 0 to 99

    static readonly...

  • RE: Problem with Grouping and max()

    Try using ROW_NUMBER instead

    WITH CTE AS (

    SELECT Username, thumbnailPhoto, [Display Name], Department, USERID, email, BADGENUMBER, NAME, CHECKTYPE, CHECKTIME,

    ROW_NUMBER() OVER(PARTITION BY USERID ORDER...

  • RE: Trigger to concatenate two columns and update in new column

    Rather than a trigger, can you change the table so that Full_Name is a calculated column?

  • RE: Addition Of Digits

    SQL Kiwi (9/24/2012)


    Handling NULL and -2147483648 is another good point (though the original test rig can produce neither value, in my defence).

    NULL can also be handled by adding 'RETURNS NULL...

  • RE: Addition Of Digits

    SQL Kiwi (9/21/2012)


    This is about twice as fast for me:

    Source:

    [font="Courier New"]    public static int SumDigits(int Input)

        {

            int sum = 0;

            for (int n = System.Math.Abs(Input); n > 0; sum += n % 10,...

Viewing 15 posts - 481 through 495 (of 1,439 total)