Forum Replies Created

Viewing 15 posts - 8,521 through 8,535 (of 10,144 total)

  • RE: Difference between two integer format number

    Thishave , after 3 characterwould indicate a VARCHAR or CHAR datatype. Check the datatypes of the columns in the tables. Try casting to INT or BIGINT the column which has...

  • RE: query

    Sure:

    DROP TABLE #T1

    CREATE TABLE #T1 (PersonId VARCHAR(2), OID VARCHAR(2))

    INSERT INTO #T1 (PersonId, OID)

    SELECT 'P1', 'O1' UNION ALL

    SELECT 'P2', 'O7' UNION ALL

    SELECT 'P3', 'O1'

    SELECT a.PersonId, (SELECT OID FROM #T1 WHERE PersonId...

  • RE: Trimming unwanted characters from string

    Don't forget a tally-table version!

    DECLARE @Untrimmed varchar(50), @Trimmed varchar(50)

    SET @Untrimmed = 'HaveNow!/7896-7'

    SET @Untrimmed = 'HaveNow'

    --

    SELECT @Trimmed = LEFT(@Untrimmed, (SELECT ISNULL(MIN(n.number)-1, LEN(@Untrimmed))

    FROM Numbers n

    WHERE n.number <= LEN(@Untrimmed)

    AND NOT ascii(lower(substring(@Untrimmed, n.number,1)))...

  • RE: Trimming unwanted characters from string

    karthur (4/9/2009)


    I have a column with 'name/dept' or 'name-dept', such as 'jones/1234' or 'jones-1234'.

    Is there a function or functions I can use in SQL Server 2005 to give me just...

  • RE: sequence in a range

    No worries Allan, though I think it's Adi who deserves the credit.

    Have a read of this when you've got a few minutes.

    Cheers

    ChrisM

  • RE: cursor goes in to infinit loop.........

    The BEGIN is in the wrong place. Here's the example from BOL:

    DECLARE Employee_Cursor CURSOR FOR

    SELECT EmployeeID, Title FROM AdventureWorks.HumanResources.Employee;

    OPEN Employee_Cursor;

    FETCH NEXT FROM Employee_Cursor;

    WHILE @@FETCH_STATUS = 0

    BEGIN

    ...

  • RE: sequence in a range

    Do you mean this?

    DROP TABLE #GroupMembers

    CREATE TABLE #GroupMembers (

    Group_member_id INT,

    Member_name VARCHAR(10),

    Group_name VARCHAR(3),

    [Order] INT)

    ...

  • RE: Multi Column Sort

    john.arnott (4/8/2009)


    OK. If the puzzle's rules specify that the given data always has increasing values in the respective columns of each row, so be it. Does that affect...

  • RE: Multi Column Sort

    RBarryYoung (4/8/2009)


    Peso (4/8/2009)


    I agree with most points, but I strongly disagree with creating sample data that fulfills OP's wanted output. I don't believe in some divine intervention that sample data...

  • RE: Multi Column Sort

    RBarryYoung (4/8/2009)


    Yeah, my data follows the rules, but plays havoc with any simple distribution assumptions.

    😀

    No fair :sick: it's only 25% populated with numbers! If that!

  • RE: Multi Column Sort

    Peso (4/8/2009)


    Ramesh (4/8/2009)


    See these results, the row 5 should be followed after row 4 as the col2 value of row 5 is higher than that of row 4.

    -- Actual Results

    ID...

  • RE: Multi Column Sort

    Peso (4/8/2009)


    For Number < 40000 I get these results

    Ramesh' Version : 2683 ms

    Peso : 1546 ms

    Here's a randomised set of 15 rows, Peso - wanna give them both a try?...

  • RE: Multi Column Sort

    Peso (4/8/2009)


    Using Ramesh's test cases, I get these timings:

    Ramesh' Version : 526 ms

    ChrisM' Version 3 ("condensed" version 2) : 23480 ms

    Peso : 236 ms

    Ooookaaaaayyyy proof of the pudding...run against randomised...

  • RE: Multi Column Sort

    36376 ms? What are you running this test on, Ramesh - a twin-floppy 80's luggable? 😀

    876 ms is awesome:cool:

  • RE: Multi Column Sort

    Very elegant! Makes my CASEy stuff look like a dustbin full of spaghetti!

    Who's gonna test with 40,000 rows then? 😀

Viewing 15 posts - 8,521 through 8,535 (of 10,144 total)