Forum Replies Created

Viewing 15 posts - 1,111 through 1,125 (of 2,458 total)

  • RE: Trouble with SUM

    vecerda (12/11/2015)


    there are none, which I know is where the problem is. But I am not sure how to change the query to translate no rows in the source table...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Using IF in where clause

    Just worth noting, in SQL 2012+ there are two "IF" statements.

    There's IF which is part of the flow control language and can't be used inside a DML query and...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: how extract values from expressions

    Another way, using delimitedsplit8K and patreplace8k (both referenced in my signature) would be like so:

    declare @testdata table(expression varchar(500))

    insert into @testdata

    SELECT expression FROM

    (values('[w1+w2+w3/5]'),('[(w1+w2+w3)/5]'),('[(w4-w5*w6)/5]')) x(expression)

    select expression, Item

    from @testdata

    CROSS APPLY...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Dynamic filtering of concatenated fields

    NP. Glad that worked for you. 😀

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Dynamic filtering of concatenated fields

    I'd like this to be done with a stored procedure that takes as its input parameter a comma delimited string such as 'straw,farm,lane' and for there to be an iteration...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Parse string from URL between...

    Another solution... This will be a smidgen slower but the code will be much cleaner. Using the Pattern-Based splitter referenced in my signature you could get the first series of...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Parse string from URL between...

    Just a couple more approaches because parsing strings is fun.

    If the string you are searching for is always going to be 7 characters long you could do this (note...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: SSRS Parameter Function for Capitalization

    Easy. Note my solution and comments:

    DECLARE @UCase bit;

    DECLARE @project varchar(10);

    -- When @UCase is 0

    SELECT @project = 'abc', @UCase = 0;

    -- Logic for your output

    SELECT PROJECT = CASE @UCase WHEN 0...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Scalar functions sudden slow down

    On a side note, and I don't know if "the sudden slow down" happened when after the scalar udfs were added, but Scalar UDFs kill parallelism. Often the whole query...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Benefits of Windows Server 2012?

    Less impressive but worth mentioning... There are some notable powershell, enhancements in 2012 that make managing your server a little easier (for those that use powershell).

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: TSQL Join question

    I just wanted to add that, if you have any control of the schema (it sounds like you might not). Just changing the DDL might make a big difference. E.g....

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Table vs View vs UserDefined Function - Which will give more performance

    Sergiy (12/7/2015)


    Alan.B (12/7/2015)


    I'm with what everyone has said so far. I would add, however, that, if you are doing aggregations, you might want to consider an indexed view with the...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Table vs View vs UserDefined Function - Which will give more performance

    I'm with what everyone has said so far. I would add, however, that, if you are doing aggregations, you might want to consider an indexed view with the aggregations indexed....

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Update to remove trailing special characters

    This is how you would remove them only at the end:

    DECLARE @table TABLE (col1 varchar(100));

    INSERT @table VALUES ('address1'),('address2'+char(10)+char(13)),('address3');

    SELECT

    CASE

    WHEN col1 LIKE '%'+char(10)+char(13)

    THEN...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Gale-Shapley algorithm

    Joe Celko has the stable marriage problem (which I believe you are looking for) in his book: SQL Puzzles and Answers 2nd edition.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

Viewing 15 posts - 1,111 through 1,125 (of 2,458 total)