Forum Replies Created

Viewing 15 posts - 76 through 90 (of 1,922 total)

  • RE: query help

    Something like thiss?

    DECLARE @InstlNo INT = 15

    DECLARE @TBL_INTRATE TABLE

    (

    SCHEMEID INT

    ,INSTLNO INT

    ,ROI INT

    )

    INSERT INTO @TBL_INTRATE

    SELECT 1, 1, 20

    UNION ALL SELECT 1,...

  • RE: Query Results problem, at my wits end....

    Please provide some sample data, table structure, business rules and expected result, like this format:

    Data:

    IF OBJECT_ID('tempdb..#t') IS NOT NULL

    DROP TABLE #t

    CREATE TABLE #T

    (

    ColA INT

    ...

  • RE: Testing that a varchar could be converted to a uniqueidentifier

    Jeff Moden (7/1/2012)


    ColdCoffee (6/29/2012)


    I would invlove an Regex-powered CLR for this task. Simple, powerfull and nasty fast.

    If it were me, I wouldn't bother with the CLR for this task because...

  • RE: Testing that a varchar could be converted to a uniqueidentifier

    I would invlove an Regex-powered CLR for this task. Simple, powerfull and nasty fast.

  • RE: Ordered group by

    _simon_ (6/29/2012)

    The row_number function with partition by is incorrect because it continues with counting instead of starting it over again when the user changes.

    My query produces the exact same output...

  • RE: Ordered group by

    This, perhaps?

    ; with cte as

    (

    select *

    , rn1 = ROW_NUMBER() over(Order by ot.code)

    ...

  • RE: trimming a text string

    Or this?

    SELECT REVERSE( LEFT (crsapp.r , CHARINDEX('_', crsapp.r)-1))

    from #testtable t

    CROSS APPLY ( SELECT t.ProdPath + '\' ) P(ProdPath)

    CROSS APPLY ( SELECT REVERSE ( SUBSTRING(P.ProdPath, 2, CHARINDEX('\',P.ProdPath,2)-2 ) )...

  • RE: UNPIVOT with where clause

    This?

    SELECT MyId ,MinAmt = MIN( Pivot_Handle.Vals )

    FROM #test T

    UNPIVOT ( Vals FOR Cols IN (MV1 , MV2, MV3, MV4)) Pivot_Handle

    WHERE Pivot_Handle.Vals >= 150

    GROUP BY MYID...

  • RE: Crosstab table update

    This?

    DECLARE @ReadingTable TABLE

    (

    Name VARCHAR(100)

    ,RED VARCHAR(100)

    ,BLUE ...

  • RE: Crosstab table update

    CASE Statement 🙂

  • RE: Query Half hourly meter reading table

    Hello Marshy100,

    Welcome to SSC. I see that you are fairly new to the site. For getting best results for your question, please read the following article on the etiquettes.

    How to...

  • RE: tsql query - Count the number of spaces in a string

    This?

    DECLARE @String VARCHAR(100)

    ,@CharToFind VARCHAR(1)

    SET @String = 'AAAA BBBCB NNNNN NEEEEE ERERERERERE '

    SET @CharToFind = ' '

    SELECT CountOfCharsInTheString = DATALENGTH...

  • RE: Aggregate Query question

    As an example:

    IF OBJECT_ID('TempDB..#Temp') IS NOT NULL

    DROP TABLE #Temp;

    CREATE TABLE #Temp

    (

    iD INT IDENTITY(1,1)

    ...

  • RE: Aggregate Query question

    I am not sure what the requirement is, but with the look of things, i sense that you need find the ID whose sum of quantity equals or greater than...

  • RE: Very simple query that has me stumped...

    I think i understood the requirement, but hey, i may be terribly misinformed :w00t:

    So, lets cook some sample data (you said 5 rows, ALWAYS)

    IF OBJECT_ID('tempdb..#Test') IS NOT NULL

    DROP TABLE #Test;

    CREATE...

Viewing 15 posts - 76 through 90 (of 1,922 total)