Forum Replies Created

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

  • RE: TSQL Case Statement help

    You're better off using inline table-valued functions. Here's an example:

    ALTER FUNCTION [dbo].[iTVF_Tester]

    (@jdt_jty_code varchar(50))

    RETURNS TABLE AS RETURN

    SELECT ReturnValue

    FROM (VALUES

    ('ISCO','Install'),

    ('ISSP','Install'),

    ('IECO','Install'),

    ('IECM','Install'),

    ('IESP','Install'),

    ('IEHD','Install'),

    ('ISHD','Install'),

    ('FRSI','Install'),

    ('SB42','Service Call'),

    ('SB4W','Service Call'),

    ('HD42','Service Call'),

    ('HD4W','Service Call'),

    ('SA2C','Service Call'),

    ('SA2W','Service Call'),

    ('HD2C','Service Call'),

    ('HD2W','Service Call'),

    ('SNCO','Service Call')

    ) x...

  • RE: TSQL Case Statement help

    Roland Alexander STL (10/2/2012)


    You're getting an error because the CASE statement needs to be enclosed in parentheses.

    I'm unaware of this as a requirement in TSQL.

    I think it's more likely because...

  • RE: TSQL Case Statement help

    Select case

    When jdt_jty_code IN ('ISCO','ISSP','IECO','IECM','IESP','IEHD','ISHD','FRSI') Then 'Install'

    When jdt_jty_code IN ('SB42','SB4W','HD42','HD4W','SA2C','SA2W','HD2C','HD2W','SNCO') Then 'Service Call'

    Else 'UNKNOWN' END

  • RE: how to avoid duplicate business logic

    norbert.manyi (10/2/2012)


    ...Ps. I understand that this particular example can be done using views, but I'm taking about the situations where you cannot do this. (I just can't find a good...

  • RE: Using MERGE for Audting

    If you are using the Enterprise edition of SS2K8, then change data capture is well worth a look.

  • RE: find increase/decrease amount

    -- you have 2 rows for sector 'A', month 1

    -- what do you want to do with them?

    -- It's not clear from your "Required Output", which...

  • RE: Are the posted questions getting worse?

    HowardW (10/2/2012)


    Anyone else eagerly awaiting this?

    Have to say, getting increasingly irate about e-book pricing. Why do I have to pay 50p more, given all the costs of printing, distributing and...

  • RE: Help needed with a query (Cursors+union+pivot?)

    gianlud75 (10/2/2012)


    ...

    What I would like to get, is something like the image in attachment

    You have to use dynamic sql for this. The core query is this:

    SELECT

    a.SURV_ID,

    [First Question] =...

  • RE: Why does this take so long!

    deepakagarwalathome (10/1/2012)


    ...There are no indexes on any of the tables...

    This might have something to do with it. The first sentence of an excellent indexing article[/url] reads "Indexes are fundamental to...

  • RE: How to eval @Variable when assigned from SELECT field?

    jmccoy-1028380 (10/1/2012)


    Yes! That works as desired. Thank You!

    Are there other ways though, for evaluating it?

    --something like:

    IF isnull(@OrderNumRtrn, 0) = 0 OR @OrderNumRtrn = '000000'

    ...

  • RE: Cross joining one table to find duplicates

    d.aarts (10/2/2012)


    I have been working on cleaning a database with addresses in an attempt to dedupe it. There's a lot of pollution and duplicates in the table. Due to efficiency...

  • RE: How can I count the number of occurances of a string in an ntext column for each record?

    Mixolydian (10/1/2012)


    Wow! I had hoped to find a response but I am overwhelmed. Thank you all very much!

    Lowell, thank you for the valuable tip. I do need to check...

  • RE: Consolidate Overlapping Date Periods

    dwain.c (10/1/2012)


    😀

    ChrisM@Work (9/28/2012)


    dwain.c (9/27/2012)


    Phil,

    I think this is a pretty snappy query too.

    <<snip>>

    Chris - I like what you did with the CROSS APPLY and I was able to do that in...

  • RE: How can I count the number of occurances of a string in an ntext column for each record?

    laurie-789651 (10/1/2012)


    laurie-789651 (10/1/2012)


    This appears to work:

    I've elected to show rows where both values are zero in case these are wrong - You can remove this if you want.

    I've set MAXRECURSION...

  • RE: How can I count the number of occurances of a string in an ntext column for each record?

    This will get you 1 and 2:

    DROP TABLE #tblHTML

    CREATE TABLE #tblHTML (RowID INT, strPage ntext)

    INSERT INTO #tblHTML (RowID, strPage)

    SELECT

    1, REPLICATE(CAST('I have a table [tblHTML] with an ntext column [strPage]...

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