Forum Replies Created

Viewing 15 posts - 1,501 through 1,515 (of 2,458 total)

  • RE: SQL Query

    DECLARE @issues TABLE(Issues varchar(5), Category char(1), IssueDate date);

    INSERT @issues VALUES

    ('I1','A','1/1/2015'),

    ('I2','A','2/2/2015'),

    ('I3','B','2/1/2015'),

    ('I4','C','3/3/2015'),

    ('I5','B','4/3/2015'),

    ('I6','A','5/4/2015');

    SELECT * FROM @issues;

    SELECT

    mo.m,

    A = SUM(CASE WHEN Category = 'A' THEN 1 ELSE 0 END),

    ...

    "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: Sql server random slow query

    RECOMPILE and Copying the parameter as a local variable will likely eliminate that possibility of parameter sniffing.

    If you normally get 10-15K reads then it goes up to 1.5M reads,...

    "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: Need Ammunition for Developers Doing Select *'s

    You can apply what I'm going to show you to your data. If you want to prove that what you are recommending is faster then visual proof is often 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: Separating results from 1 column

    First, welcome to SQL Server Central! See the link in my signature line to the article on how to best ask questions here. The small amount of time it takes...

    "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: Bulk Delete & Insert

    I don't understand from your explanation what that other table is doing for you.

    Adding to what Bill said - why not remove all indexes and constraints from the 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: TempDB files i/o issue.

    Hard to say, it could be a lot of things. What I can say for sure is splitting the data into more files will help and separating the ldfs 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: Sum Help

    I have nothing to add to this post except to say that I love the title, "Sum Help". It would be even better if the title was, "I need sum...

    "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: TempDB files i/o issue.

    Tac11 (5/12/2015)


    I ran following Glen Berry's query on my Prod server:

    SELECT DB_NAME(fs.database_id) AS [Database Name], mf.physical_name, io_stall_read_ms, num_of_reads,

    CAST(io_stall_read_ms/(1.0 + num_of_reads) AS NUMERIC(10,1)) AS [avg_read_stall_ms],io_stall_write_ms,

    num_of_writes,CAST(io_stall_write_ms/(1.0+num_of_writes) AS NUMERIC(10,1)) AS [avg_write_stall_ms],

    io_stall_read_ms +...

    "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: The Case for Scalar-valued, User-defined Functions in T-SQL

    I love this article Dwain. Very good work as always. 5 stars from me. I particularly enjoy how your hierarchies example - very clever.

    I do want to add -...

    "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: The Case for Scalar-valued, User-defined Functions in T-SQL

    peter-757102 (5/12/2015)


    It might be my memory...

    I distinctly remember that in the past any function used in a constraint needed to be deterministic.

    Querying a table violates that rule, obviously.

    When did this...

    "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: Index on calculated field with UDF?

    Jeff Moden (5/11/2015)


    Alan.B (5/11/2015)


    Yes and Yes no. If you post an example of what you are trying to do specifically we can provide a specific example.

    If you are talking about...

    "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: Index on calculated field with UDF?

    Jeff Moden (5/11/2015)


    Alan.B (5/11/2015)


    Yes and Yes no. If you post an example of what you are trying to do specifically we can provide a specific example.

    If you are talking about...

    "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: Query

    Glad that worked. Happy to help.

    "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 like to identify a value that contains alpha-numeric values other thna A-Z

    spaghettidba (5/11/2015)


    LIKE would do as well:

    WHERE ex NOT LIKE '%[^A-G0-9]%'

    ... and would be better than what I posted. I have not finished my coffee this morning and need to do...

    "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: Index on calculated field with UDF?

    Yes and Yes no. If you post an example of what you are trying to do specifically we can provide a specific example.

    If you are talking about doing something like...

    "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,501 through 1,515 (of 2,458 total)