Forum Replies Created

Viewing 15 posts - 1,636 through 1,650 (of 2,458 total)

  • RE: Help with dynamic SQL

    Can you include the DDL for the temp tables?

    "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: Tune SQL Server 2008 Stored procedure

    djacobos (4/7/2015)


    I am using 2 splitter function.

    ALTER FUNCTION [dbo].[CommaListIntoTable] (@InStr VARCHAR(MAX))

    RETURNS @TempTab TABLE

    (id int not null)

    AS

    BEGIN

    ;-- Ensure input ends with comma

    SET @InStr = REPLACE(@InStr + ',', ',,',...

    "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: Tune SQL Server 2008 Stored procedure

    MadAdmin (4/7/2015)


    Sean Lange (4/7/2015)


    MadAdmin (4/7/2015)


    Read committed also has it's issues.

    It is possible to read the same row twice with read committed, once before a change, then after the change.

    All isolation...

    "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 to reduce execution time of median calculations

    Dwain Camps wrote a great article awhile back: The Performance of the T-SQL Window Functions[/url]

    The article is very 2012-centric but discusses how to calculate a median in 2008 as well.

    "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: ?? Cross Apply error...

    Here's a better example using multiple nodes on the second apply

    DECLARE @x TABLE (id int identity, data xml);

    INSERT @x VALUES

    ('

    <xxx blah="xml1">

    <yyy>123</yyy>

    <yyy>456</yyy>

    <yyy>789</yyy>

    </xxx>

    '),

    ('

    <xxx blah="xml2">

    <yyy>999</yyy>

    ...

    "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: ?? Cross Apply error...

    Note this query (created simplified XML data since there was no DDL to work with).

    DECLARE @x TABLE (id int identity, data xml);

    INSERT @x VALUES('<xxx><yyy>123</yyy><zzz>999</zzz></xxx>');

    SELECT

    id,

    n2.value('xxx[1]/yyy[1]', 'varchar(10)'),

    n1.value('.[1]', 'varchar(10)')

    FROM @x x

    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: Stored procedure taking longer in Prod

    Deadlocks will present themselves as errors, not just a long running proc.

    Yep. Duh! Good catch Grant.

    "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: Tune SQL Server 2008 Stored procedure

    Careful with that read uncommitted, it could allow incorrect data to get inserted into #MainLocationsTempFL. That's the same as a NOLOCK table hint which, if you read books online, can...

    "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: Named pipes Provider error

    dopydb (4/7/2015)


    ahh..

    i forgot to change the over write data source and reports to True - hence my changes where not applying

    stupid me !

    Haha - I do that all 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: Stored procedure taking longer in Prod

    When I have had this kind of problem it often has to do with the indexes or statistics. A few things to check:

    Make sure that

    * your statistics are up-to-date...

    "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: Creating a delimited string

    Using the technique outlined in Creating a comma-separated list (SQL Spackle)[/url] By Wayne Sheffield you could do this:

    WITH de AS

    (

    SELECT DISTINCT Email

    FROM #emails

    )

    SELECT

    Email,

    BranchNumber = STUFF((

    SELECT ',' + BranchNumber

    FROM #emails...

    "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: Storing Dynamic Query Output in Temp Table

    sarath.tata (4/6/2015)


    I can't use global temp variables as it differs per request.

    He said global temp table (e.g. ##temp). Global temp tables can be referenced inside/outside of a dynamic...

    "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: Named pipes Provider error

    The [5] would suggest that it's an authentication issue (access denied). E.g. The account that you are running SSRS on the remote server does not have rights to that server/DB....

    "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 APPLY to make your queries DRYer

    Fabulous article. Very good read. 5 stars.

    "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: Spam topics

    Eirikur Eiriksson (4/3/2015)


    Alan.B (4/3/2015)


    Koen Verbeeck (4/3/2015)


    Alan.B (4/3/2015)


    I actually came into the "Anything that is NOT about SQL!" forum to ask this question but think it's appropriate here....

    How do you report...

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