Forum Replies Created

Viewing 15 posts - 196 through 210 (of 1,082 total)

  • RE: replace

    make sure you understand the code incase the business rules change.

    the last post of mine will always replace the 3rd last char...

  • RE: replace

    try this one:

    SELECT STUFF(@String,(LEN(@String)-2),1,'V')

    Or

    SELECT REVERSE(STUFF(REVERSE(@String),3,1,'V'))

  • RE: replace

    here are all 3 example:

    DECLARE @String VARCHAR(100)

    SET @String = '234$123,N,N'

    SELECT STUFF(@String,CHARINDEX('N',@String),1,'V') as [Replace 1st N]

    SELECT STUFF(@String,9,1,'V') as [Replace 9th Char]

    SELECT STUFF(@String,PATINDEX('%[A-Z]%',@String),1,'V') as [Replace 1st Alpa char]

  • RE: replace

    is the query gonna always replace the first 'N' in your string with V or is your query gonna always replace the 9th position with V or will it always...

  • RE: Newbie question for small query

    Hi Again,

    Sorry I have been on holiday for the last 2 weeks 🙂

    Do you still an explanation?

    Thanks

    Chris

  • RE: rewrite CURSOR code, can I use an incrementing counter?

    Then I would says that what Lynn and I have posted with regards to the cross apply is what you looking for.

    HOWEVER. because you going to be using multiline functions...

  • RE: rewrite CURSOR code, can I use an incrementing counter?

    ok I see...

    Would it be possible to see the function?

    That way we can help you optimise the query.

  • RE: rewrite CURSOR code, can I use an incrementing counter?

    sorry miss understanding.

    When you say you can't get ride of the tvf! why is that?

    I'm saying don't change or delete or alter the tvf. just leave it in the DB...

  • RE: rewrite CURSOR code, can I use an incrementing counter?

    use the tally solution

  • RE: Column values as Aliases instead of columns

    try this

    CREATE TABLE InputFields

    (

    InputFieldsID INT,

    InputFieldName VARCHAR(100)

    )

    -----------------------------------

    INSERT INTO InputFields

    SELECT 1 ,'Name' UNION ALL

    SELECT 2, 'Claim #' UNION ALL

    SELECT 3, 'Email'

    CREATE TABLE InputValues

    (

    InputValueID INT,

    InputFieldsID INT,

    InputFieldValue VARCHAR(100),

    RowValue INT

    )

    ---------------------------------------------------------------

    INSERT INTO InputValues...

  • RE: rewrite CURSOR code, can I use an incrementing counter?

    P.S if you wanted to use the function method then you would need something like a cross apply.

    select *

    from @tblDriver

    CROSS APPLY dbo.tvfGetNumbers (StartNum)

    However this would not be great code...

  • RE: rewrite CURSOR code, can I use an incrementing counter?

    Would this work?

    It requires a tally table but does not require a function

    SELECT

    RecNo,

    StartNum + N -1

    FROM @tblDriver, Tally

    WHERE N < 4

  • RE: How to Merge a row

    I'm not sure how your data is in your table but I think this is what you looking for:

    DECLARE @YourTable TABLE

    (

    ct_code INT,

    type CHAR(1),

    gm_id INT,

    gl_id INT

    )

    INSERT INTO @YourTable

    SELECT 201,'D', 1, NULL...

  • RE: Newbie question for small query

    if it's null it's because there are no costs for that column.

    You could use isnull around the cost values to so Zero or add a where clause to exlude rows...

  • RE: IDENTITY seed/increment not resetting after transaction rollbacks

    Hi Jack,

    Yeah concurrency is a problem with the solution provided.

    The DBCC reseed to 0 then a reseed will always give you the next avaible seed value.

    However I am with...

Viewing 15 posts - 196 through 210 (of 1,082 total)