Forum Replies Created

Viewing 15 posts - 8,506 through 8,520 (of 10,144 total)

  • RE: Slow unions

    Hello

    Two quick suggestions.

    Firstly, merging the rows:

    select a.*, '#' AS '#', b.*

    from db..table a with (nolock)

    LEFT JOIN db..table b ON b.id = a.id + 1 and b.RecordType='C'

    where b.id in (944770735,944770759,948267730,948267745)

    Secondly...

  • RE: Multi Column Sort

    Peso (4/13/2009)


    Greate job Chris!

    But you too will have to check for mutually exclusive records as with Mr Magoos test data.

    EDIT: I tried your algorithm with the sample data provided by...

  • RE: Multi Column Sort

    It will work with a more sparse data set than the one provided by Barry too. Here's how it works:

    Determine the minimum values for each column

    Identify the row which contains...

  • RE: how to increment id value in store procedure if id is primary key

    Please post the script for the table, this will help to clarify your requirement.

  • RE: Multi Column Sort

    RBarryYoung (4/10/2009)


    Nice explanation, Peso.

    Of course, in this example you are assuming that the first record is easy to identify, but even that is not necessarily so.

    It sounds very...

  • RE: Are the posted questions getting worse?

    Steve Jones - Editor (4/8/2009)


    I'm not sure Jeff will get that one done, so someone else feel free to tackle it. He's agreed to start a nice T-SQL book for...

  • RE: SQL 2000 Query to select the nth row from a Table

    arun_anand09 (4/9/2009)


    Yes sorry I forgot to mention I have a UNIQUEID Column which starts from 1 and I need to pick 13th row based on this Unique ID.

    Whats the...

  • RE: Generating a table with records with all possible values from frequency and interval columns

    Hey Flo that was quick:-P

    DECLARE @Reference_number VARCHAR(6),

    @Amount MONEY,

    @Start_payment_date DATETIME,

    @interval_type CHAR(1),

    @interval_unit SMALLINT, @sql VARCHAR(200)

    SELECT @Reference_number = '100001',

    @Amount = 100.0,

    @Start_payment_date = '15 may 2009',

    @interval_type = 'm', --(monthly)

    @interval_unit = 1

    SELECT @Reference_number AS [Reference_number],...

  • RE: Possible invalid data?

    ben.rosato (4/9/2009)


    Well, that'll learn me. This was sent to me by someone else and I didn't really verify if the 2 CASTS actually fixed it even though he said...

  • RE: Possible invalid data?

    Next:

    A.[vchUser3] in (103235, 103236)

    toA.[vchUser3] in ('103235', '103236')

  • RE: Possible invalid data?

    Then a brief process of elimination:

    SELECT E.[IncidentID], CAST(E.[IncidentID] AS NVARCHAR(25))

    FROM store.dbo.orders E

    WHERE CAST(E.[IncidentID] AS NVARCHAR(25)) LIKE '%.%'

    Edit to add comment: This is the only column which doesn't have an "i"...

  • RE: Possible invalid data?

    ben.rosato (4/9/2009)


    If you change the last join to the following it works:

    Inner JOIN store.dbo.orders E

    ON CAST(A.[iSystemId] AS NVARCHAR(25)) = CAST(E.[IncidentID] AS NVARCHAR(25))

    Both of those colums are indeed int

    Try this: Inner...

  • RE: Trimming unwanted characters from string

    You're totally right Flo, it's overkill, all you need is patindex. It was just for fun.

    Try this:

    ISNULL(NULLIF(PATINDEX('%[^A-Z]%', NameTrim),0), LEN(NameTrim))

    which means: if patindex returns 0, replace it with null, so you...

  • RE: Avoiding cursors

    Scott (4/9/2009)


    I have a two column table:

    TRX_CODE TRXID

    AAA1 19212312

    AAA1 ...

  • RE: How to sort alphanumeric values

    manohar (4/9/2009)


    Arun....

    Ur logic works only in the case of alphanumeric values... I throws error in case of string

    The error is

    ------

    Msg 245, Level 16, State 1, Line 17

    Conversion failed when...

Viewing 15 posts - 8,506 through 8,520 (of 10,144 total)