SQL Server Performance Issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andres Rormoser

    SQL Server Performance Issue

    I'm having a performance Issue with my Production SQL Server (2 x Xeon
    Dual-Core Woodcrest 1.6Ghz, 2GB RAM, IIS, SQL Server). In general the
    querys take much longer than the querys in my development server . For
    example a recursive UDF takes 20s in my development server and 2m in
    my production server (both with same users load) but my production
    server it's much hardware powerfull than the other server.

    I start monitoring an realized that the Prod. Server consumes a lot of
    Physical Disk Reads and Writes when i execute this example UDF query,
    then I realized that the Prod. Server has a SATA RAID1 Disk Mirroring
    and my Dev. Server do not has mirroring.

    It seems that the RAID1 disk performance seems to be very important
    when I execute this query, and my question is WHY??

    If the query only reads one Table 'CentroCostos' witch has 1255
    records, why DISK performance is so important? It should work with
    this info on memory and not have to use so much disk i/o.

    Please help me understand this to solve this problem.

    Thanks, AR



    SET QUOTED_IDENTIFI ER OFF
    go
    SET ANSI_NULLS OFF
    go
    CREATE FUNCTION dbo.fn_CentroCo sto (@ccs_ids VARCHAR(4000))
    RETURNS @Ret TABLE (ccs_id INT)
    AS
    BEGIN
    DECLARE @ccs_ccs_id INT, @cantidad INT, @ccs_id INT

    IF @ccs_ids = 'null'
    RETURN

    SELECT @cantidad = COUNT(*) FROM dbo.fn_split(@c cs_ids,',')

    IF @cantidad = 1
    BEGIN
    SELECT @cantidad = COUNT(*) FROM CentroCosto WHERE ccs_ccs_id
    = @ccs_ids
    IF @cantidad = 0
    BEGIN
    INSERT INTO @Ret SELECT @ccs_ids
    RETURN
    END
    ELSE
    BEGIN
    INSERT INTO @Ret SELECT @ccs_ids
    DECLARE ListadoCcs CURSOR FOR ( SELECT ccs_id FROM
    CentroCosto WHERE ccs_ccs_id = @ccs_ids )
    OPEN ListadoCcs
    FETCH NEXT FROM ListadoCcs INTO @ccs_id
    WHILE @@FETCH_STATUS = 0
    BEGIN
    INSERT INTO
    @Ret
    SELECT
    a.ccs_id
    FROM
    dbo.fn_CentroCo sto(@ccs_id) As a

    FETCH NEXT FROM ListadoCcs INTO @ccs_id
    END
    CLOSE ListadoCcs
    DEALLOCATE ListadoCcs
    END
    END
    ELSE
    BEGIN
    DECLARE ListadoCcs CURSOR FOR ( SELECT a.Value FROM
    dbo.fn_split(@c cs_ids,',') AS a )
    OPEN ListadoCcs
    FETCH NEXT FROM ListadoCcs INTO @ccs_id
    WHILE @@FETCH_STATUS = 0
    BEGIN
    INSERT INTO
    @Ret
    SELECT
    ccs_id
    FROM
    dbo.fn_CentroCo sto(@ccs_id)
    WHERE
    ccs_id not in (select ccs_id from
    @Ret)

    FETCH NEXT FROM ListadoCcs INTO @ccs_id
    END

    CLOSE ListadoCcs
    DEALLOCATE ListadoCcs
    END
    RETURN
    END
    go
    SET ANSI_NULLS OFF
    go
    SET QUOTED_IDENTIFI ER OFF
    go
    IF OBJECT_ID('dbo. fn_CentroCosto' ) IS NOT NULL
    PRINT '<<< CREATED FUNCTION dbo.fn_CentroCo sto >>>'
    ELSE
    PRINT '<<< FAILED CREATING FUNCTION dbo.fn_CentroCo sto >>>'
    go
  • Jack Vamvas

    #2
    Re: SQL Server Performance Issue

    Firstly , could you confirm the 2 dbs are similar in terms of
    indices,statist ics and execution plans. For example, when your run the UDF
    are they similar exceution plans?

    --

    Jack Vamvas
    _______________ _______________ _____
    Search IT jobs from multiple sources- http://www.ITjobfeed.com




    "Andres Rormoser" <arormoser@gmai l.comwrote in message
    news:6d10d455-0c58-4aec-a928-1cf3c31b0bc0@i7 g2000prf.google groups.com...
    I'm having a performance Issue with my Production SQL Server (2 x Xeon
    Dual-Core Woodcrest 1.6Ghz, 2GB RAM, IIS, SQL Server). In general the
    querys take much longer than the querys in my development server . For
    example a recursive UDF takes 20s in my development server and 2m in
    my production server (both with same users load) but my production
    server it's much hardware powerfull than the other server.
    >
    I start monitoring an realized that the Prod. Server consumes a lot of
    Physical Disk Reads and Writes when i execute this example UDF query,
    then I realized that the Prod. Server has a SATA RAID1 Disk Mirroring
    and my Dev. Server do not has mirroring.
    >
    It seems that the RAID1 disk performance seems to be very important
    when I execute this query, and my question is WHY??
    >
    If the query only reads one Table 'CentroCostos' witch has 1255
    records, why DISK performance is so important? It should work with
    this info on memory and not have to use so much disk i/o.
    >
    Please help me understand this to solve this problem.
    >
    Thanks, AR
    >
    >
    >
    SET QUOTED_IDENTIFI ER OFF
    go
    SET ANSI_NULLS OFF
    go
    CREATE FUNCTION dbo.fn_CentroCo sto (@ccs_ids VARCHAR(4000))
    RETURNS @Ret TABLE (ccs_id INT)
    AS
    BEGIN
    DECLARE @ccs_ccs_id INT, @cantidad INT, @ccs_id INT
    >
    IF @ccs_ids = 'null'
    RETURN
    >
    SELECT @cantidad = COUNT(*) FROM dbo.fn_split(@c cs_ids,',')
    >
    IF @cantidad = 1
    BEGIN
    SELECT @cantidad = COUNT(*) FROM CentroCosto WHERE ccs_ccs_id
    = @ccs_ids
    IF @cantidad = 0
    BEGIN
    INSERT INTO @Ret SELECT @ccs_ids
    RETURN
    END
    ELSE
    BEGIN
    INSERT INTO @Ret SELECT @ccs_ids
    DECLARE ListadoCcs CURSOR FOR ( SELECT ccs_id FROM
    CentroCosto WHERE ccs_ccs_id = @ccs_ids )
    OPEN ListadoCcs
    FETCH NEXT FROM ListadoCcs INTO @ccs_id
    WHILE @@FETCH_STATUS = 0
    BEGIN
    INSERT INTO
    @Ret
    SELECT
    a.ccs_id
    FROM
    dbo.fn_CentroCo sto(@ccs_id) As a
    >
    FETCH NEXT FROM ListadoCcs INTO @ccs_id
    END
    CLOSE ListadoCcs
    DEALLOCATE ListadoCcs
    END
    END
    ELSE
    BEGIN
    DECLARE ListadoCcs CURSOR FOR ( SELECT a.Value FROM
    dbo.fn_split(@c cs_ids,',') AS a )
    OPEN ListadoCcs
    FETCH NEXT FROM ListadoCcs INTO @ccs_id
    WHILE @@FETCH_STATUS = 0
    BEGIN
    INSERT INTO
    @Ret
    SELECT
    ccs_id
    FROM
    dbo.fn_CentroCo sto(@ccs_id)
    WHERE
    ccs_id not in (select ccs_id from
    @Ret)
    >
    FETCH NEXT FROM ListadoCcs INTO @ccs_id
    END
    >
    CLOSE ListadoCcs
    DEALLOCATE ListadoCcs
    END
    RETURN
    END
    go
    SET ANSI_NULLS OFF
    go
    SET QUOTED_IDENTIFI ER OFF
    go
    IF OBJECT_ID('dbo. fn_CentroCosto' ) IS NOT NULL
    PRINT '<<< CREATED FUNCTION dbo.fn_CentroCo sto >>>'
    ELSE
    PRINT '<<< FAILED CREATING FUNCTION dbo.fn_CentroCo sto >>>'
    go

    Comment

    • Andres Rormoser

      #3
      Re: SQL Server Performance Issue

      Yes, the database are exactly the same (it's a restore from the
      previous day) .

      Exactly the same Execution Plans. I already update statics in the
      database, also measure Memory/CPU/Virtual Memory/Disk I/O.

      But can determine where the problem is. Now i'm installing a RAID 1 in
      my development machine, to test if that is the problem, but i don't
      think so.

      On 15 feb, 16:54, "Jack Vamvas" <DEL_TO_RE...@d el.comwrote:
      Firstly , could you confirm the 2 dbs are similar in terms of
      indices,statist ics and execution plans. For example, when your run the UDF
      are they similar exceution plans?
      >
      --
      >
      Jack Vamvas
      _______________ _______________ _____
      Search  IT jobs from multiple sources-  http://www.ITjobfeed.com
      >
      "Andres Rormoser" <arormo...@gmai l.comwrote in message
      >
      news:6d10d455-0c58-4aec-a928-1cf3c31b0bc0@i7 g2000prf.google groups.com...
      >
      >
      >
      I'm having a performance Issue with my Production SQL Server (2 x Xeon
      Dual-Core Woodcrest 1.6Ghz, 2GB RAM, IIS, SQL Server). In general the
      querys take much longer than the querys in my development server . For
      example a recursive UDF takes 20s in my development server and 2m in
      my production server (both with same users load) but my production
      server it's much hardware powerfull than the other server.
      >
      I start monitoring an realized that the Prod. Server consumes a lot of
      Physical Disk Reads and Writes when i execute this example UDF query,
      then I realized that the Prod. Server has a SATA RAID1 Disk Mirroring
      and my Dev. Server do not has mirroring.
      >
      It seems that the RAID1 disk performance seems to be very important
      when I execute this query, and my question is WHY??
      >
      If the query only reads one Table 'CentroCostos' witch has 1255
      records, why DISK performance is so important? It should work with
      this info on memory and not have to use so much disk i/o.
      >
      Please help me understand this to solve this problem.
      >
      Thanks, AR
      >
      SET QUOTED_IDENTIFI ER OFF
      go
      SET ANSI_NULLS OFF
      go
      CREATE FUNCTION dbo.fn_CentroCo sto (@ccs_ids VARCHAR(4000))
      RETURNS @Ret TABLE (ccs_id INT)
      AS
      BEGIN
         DECLARE @ccs_ccs_id INT, @cantidad INT, @ccs_id INT
      >
         IF @ccs_ids = 'null'
             RETURN
      >
         SELECT @cantidad = COUNT(*) FROM dbo.fn_split(@c cs_ids,',')
      >
         IF @cantidad = 1
         BEGIN
             SELECT @cantidad = COUNT(*) FROM CentroCosto WHERE ccs_ccs_id
      = @ccs_ids
             IF @cantidad = 0
             BEGIN
                 INSERT INTO @Ret SELECT @ccs_ids
                 RETURN
             END
             ELSE
             BEGIN
                 INSERT INTO @Ret SELECT @ccs_ids
                 DECLARE ListadoCcs CURSOR FOR ( SELECT ccs_id FROM
      CentroCosto WHERE ccs_ccs_id = @ccs_ids )
                 OPEN ListadoCcs
                 FETCH NEXT FROM ListadoCcs INTO @ccs_id
                 WHILE @@FETCH_STATUS = 0
                 BEGIN
                     INSERT INTO
                         @Ret
                     SELECT
                         a.ccs_id
                     FROM
                         dbo.fn_CentroCo sto(@ccs_id) As a
      >
                     FETCH NEXT FROM ListadoCcs INTO @ccs_id
                 END
                 CLOSE ListadoCcs
                 DEALLOCATE ListadoCcs
             END
         END
         ELSE
         BEGIN
             DECLARE ListadoCcs CURSOR FOR ( SELECT a.Value FROM
      dbo.fn_split(@c cs_ids,',') AS a )
             OPEN ListadoCcs
             FETCH NEXT FROM ListadoCcs INTO @ccs_id
             WHILE @@FETCH_STATUS = 0
             BEGIN
                 INSERT INTO
                     @Ret
                 SELECT
                     ccs_id
                 FROM
                     dbo.fn_CentroCo sto(@ccs_id)
                 WHERE
                     ccs_id not in (select ccs_id from
      @Ret)
      >
                 FETCH NEXT FROM ListadoCcs INTO @ccs_id
             END
      >
             CLOSE ListadoCcs
             DEALLOCATE ListadoCcs
         END
         RETURN
      END
      go
      SET ANSI_NULLS OFF
      go
      SET QUOTED_IDENTIFI ER OFF
      go
      IF OBJECT_ID('dbo. fn_CentroCosto' ) IS NOT NULL
         PRINT '<<< CREATED FUNCTION dbo.fn_CentroCo sto >>>'
      ELSE
         PRINT '<<< FAILED CREATING FUNCTION dbo.fn_CentroCo sto >>>'
      go- Ocultar texto de la cita -
      >
      - Mostrar texto de la cita -

      Comment

      • Andres Rormoser

        #4
        Re: SQL Server Performance Issue

        Also we test other heavy queries and they work OK in both machines, it
        seems that the problem is when the query use this specific UDF.

        On 15 feb, 17:43, Andres Rormoser <arormo...@gmai l.comwrote:
        Yes, the database are exactly the same (it's a restore from the
        previous day) .
        >
        Exactly the same Execution Plans. I already update statics in the
        database, also measure Memory/CPU/Virtual Memory/Disk I/O.
        >
        But can determine where the problem is. Now i'm installing a RAID 1 in
        my development machine, to test if that is the problem, but i don't
        think so.
        >
        On 15 feb, 16:54, "Jack Vamvas" <DEL_TO_RE...@d el.comwrote:
        >
        >
        >
        Firstly , could you confirm the 2 dbs are similar in terms of
        indices,statist ics and execution plans. For example, when your run the UDF
        are they similar exceution plans?
        >
        --
        >
        Jack Vamvas
        _______________ _______________ _____
        Search  IT jobs from multiple sources-  http://www.ITjobfeed.com
        >
        "Andres Rormoser" <arormo...@gmai l.comwrote in message
        >
        news:6d10d455-0c58-4aec-a928-1cf3c31b0bc0@i7 g2000prf.google groups.com...
        >
        I'm having a performance Issue with my Production SQL Server (2 x Xeon
        Dual-Core Woodcrest 1.6Ghz, 2GB RAM, IIS, SQL Server). In general the
        querys take much longer than the querys in my development server . For
        example a recursive UDF takes 20s in my development server and 2m in
        my production server (both with same users load) but my production
        server it's much hardware powerfull than the other server.
        >
        I start monitoring an realized that the Prod. Server consumes a lot of
        Physical Disk Reads and Writes when i execute this example UDF query,
        then I realized that the Prod. Server has a SATA RAID1 Disk Mirroring
        and my Dev. Server do not has mirroring.
        >
        It seems that the RAID1 disk performance seems to be very important
        when I execute this query, and my question is WHY??
        >
        If the query only reads one Table 'CentroCostos' witch has 1255
        records, why DISK performance is so important? It should work with
        this info on memory and not have to use so much disk i/o.
        >
        Please help me understand this to solve this problem.
        >
        Thanks, AR
        >
        SET QUOTED_IDENTIFI ER OFF
        go
        SET ANSI_NULLS OFF
        go
        CREATE FUNCTION dbo.fn_CentroCo sto (@ccs_ids VARCHAR(4000))
        RETURNS @Ret TABLE (ccs_id INT)
        AS
        BEGIN
           DECLARE @ccs_ccs_id INT, @cantidad INT, @ccs_id INT
        >
           IF @ccs_ids = 'null'
               RETURN
        >
           SELECT @cantidad = COUNT(*) FROM dbo.fn_split(@c cs_ids,',')
        >
           IF @cantidad = 1
           BEGIN
               SELECT @cantidad = COUNT(*) FROM CentroCosto WHERE ccs_ccs_id
        = @ccs_ids
               IF @cantidad = 0
               BEGIN
                   INSERT INTO @Ret SELECT @ccs_ids
                   RETURN
               END
               ELSE
               BEGIN
                   INSERT INTO @Ret SELECT @ccs_ids
                   DECLARE ListadoCcs CURSOR FOR ( SELECT ccs_id FROM
        CentroCosto WHERE ccs_ccs_id = @ccs_ids )
                   OPEN ListadoCcs
                   FETCH NEXT FROM ListadoCcs INTO @ccs_id
                   WHILE @@FETCH_STATUS = 0
                   BEGIN
                       INSERT INTO
                           @Ret
                       SELECT
                           a.ccs_id
                       FROM
                           dbo.fn_CentroCo sto(@ccs_id) As a
        >
                       FETCH NEXT FROM ListadoCcs INTO @ccs_id
                   END
                   CLOSE ListadoCcs
                   DEALLOCATE ListadoCcs
               END
           END
           ELSE
           BEGIN
               DECLARE ListadoCcs CURSOR FOR ( SELECT a.Value FROM
        dbo.fn_split(@c cs_ids,',') AS a )
               OPEN ListadoCcs
               FETCH NEXT FROM ListadoCcs INTO @ccs_id
               WHILE @@FETCH_STATUS = 0
               BEGIN
                   INSERT INTO
                       @Ret
                   SELECT
                       ccs_id
                   FROM
                       dbo.fn_CentroCo sto(@ccs_id)
                   WHERE
                       ccs_id not in (select ccs_id from
        @Ret)
        >
                   FETCH NEXT FROM ListadoCcs INTO @ccs_id
               END
        >
               CLOSE ListadoCcs
               DEALLOCATE ListadoCcs
           END
           RETURN
        END
        go
        SET ANSI_NULLS OFF
        go
        SET QUOTED_IDENTIFI ER OFF
        go
        IF OBJECT_ID('dbo. fn_CentroCosto' ) IS NOT NULL
           PRINT '<<< CREATED FUNCTION dbo.fn_CentroCo sto >>>'
        ELSE
           PRINT '<<< FAILED CREATING FUNCTION dbo.fn_CentroCo sto >>>'
        go- Ocultar texto de la cita -
        >
        - Mostrar texto de la cita -- Ocultar texto de la cita -
        >
        - Mostrar texto de la cita -

        Comment

        • Erland Sommarskog

          #5
          Re: SQL Server Performance Issue

          Andres Rormoser (arormoser@gmai l.com) writes:
          I'm using SQL Server 2000 8.00.2039.
          >
          I finnaly solve the problem!! The clasic restart! I restarted the SQL
          Server and now it's working in 15s like it should.
          No, that operation should run in far less than 15s if you coded
          it properly. It's more difficult than on SQL 2005, but I'm still
          prepare to take the challenge if I get the tables and data to play
          with.
          Now, my question is why? It's a good practice to restart SQL server
          every x days? Memory related issues? Is there any DBCC command to
          "clean" memory?
          No, it's definitely not a good idea to restart SQL Server on regular
          basis. That is just a waste of time.

          It sounds that you simply were the victim of a poor execution plan.
          When SQL Server first biulds the execition for a function or a stored
          procedure, it sniffs the input parameters and uses these values as
          guidance. If the first call is with atypical parameters, this can lead
          to a less good plan for the common case. In such case you could have
          achieved the same result with sp_recompile on your function to flush
          the plan for from the cache.



          --
          Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

          Books Online for SQL Server 2005 at

          Books Online for SQL Server 2000 at

          Comment

          • Dan Guzman

            #6
            Re: SQL Server Performance Issue

            No, it's definitely not a good idea to restart SQL Server on regular
            basis. That is just a waste of time.
            >
            It sounds that you simply were the victim of a poor execution plan.
            This is the same conclusion I came to in the parallel thread in
            microsoft.publi c.sqlserver.ser ver.

            --
            Hope this helps.

            Dan Guzman
            SQL Server MVP


            "Erland Sommarskog" <esquel@sommars kog.sewrote in message
            news:Xns9A48EF0 C45DB9Yazorman@ 127.0.0.1...
            Andres Rormoser (arormoser@gmai l.com) writes:
            >I'm using SQL Server 2000 8.00.2039.
            >>
            >I finnaly solve the problem!! The clasic restart! I restarted the SQL
            >Server and now it's working in 15s like it should.
            >
            No, that operation should run in far less than 15s if you coded
            it properly. It's more difficult than on SQL 2005, but I'm still
            prepare to take the challenge if I get the tables and data to play
            with.
            >
            >Now, my question is why? It's a good practice to restart SQL server
            >every x days? Memory related issues? Is there any DBCC command to
            >"clean" memory?
            >
            No, it's definitely not a good idea to restart SQL Server on regular
            basis. That is just a waste of time.
            >
            It sounds that you simply were the victim of a poor execution plan.
            When SQL Server first biulds the execition for a function or a stored
            procedure, it sniffs the input parameters and uses these values as
            guidance. If the first call is with atypical parameters, this can lead
            to a less good plan for the common case. In such case you could have
            achieved the same result with sp_recompile on your function to flush
            the plan for from the cache.
            >
            >
            >
            --
            Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se
            >
            Books Online for SQL Server 2005 at

            Books Online for SQL Server 2000 at
            http://www.microsoft.com/sql/prodinf...ons/books.mspx

            Comment

            • Dan Guzman

              #7
              Re: SQL Server Performance Issue

              Andres, please don't post the same question independently to multiple groups
              as this causes duplication of effort. Instead, post the question once with
              cross-post to other relevant groups.

              There is additional information waiting for you in the
              microsoft.publi c.sqlserver.ser ver thread.

              --
              Hope this helps.

              Dan Guzman
              SQL Server MVP


              "Andres Rormoser" <arormoser@gmai l.comwrote in message
              news:6d10d455-0c58-4aec-a928-1cf3c31b0bc0@i7 g2000prf.google groups.com...
              I'm having a performance Issue with my Production SQL Server (2 x Xeon
              Dual-Core Woodcrest 1.6Ghz, 2GB RAM, IIS, SQL Server). In general the
              querys take much longer than the querys in my development server . For
              example a recursive UDF takes 20s in my development server and 2m in
              my production server (both with same users load) but my production
              server it's much hardware powerfull than the other server.
              >
              I start monitoring an realized that the Prod. Server consumes a lot of
              Physical Disk Reads and Writes when i execute this example UDF query,
              then I realized that the Prod. Server has a SATA RAID1 Disk Mirroring
              and my Dev. Server do not has mirroring.
              >
              It seems that the RAID1 disk performance seems to be very important
              when I execute this query, and my question is WHY??
              >
              If the query only reads one Table 'CentroCostos' witch has 1255
              records, why DISK performance is so important? It should work with
              this info on memory and not have to use so much disk i/o.
              >
              Please help me understand this to solve this problem.
              >
              Thanks, AR
              >
              >
              >
              SET QUOTED_IDENTIFI ER OFF
              go
              SET ANSI_NULLS OFF
              go
              CREATE FUNCTION dbo.fn_CentroCo sto (@ccs_ids VARCHAR(4000))
              RETURNS @Ret TABLE (ccs_id INT)
              AS
              BEGIN
              DECLARE @ccs_ccs_id INT, @cantidad INT, @ccs_id INT
              >
              IF @ccs_ids = 'null'
              RETURN
              >
              SELECT @cantidad = COUNT(*) FROM dbo.fn_split(@c cs_ids,',')
              >
              IF @cantidad = 1
              BEGIN
              SELECT @cantidad = COUNT(*) FROM CentroCosto WHERE ccs_ccs_id
              = @ccs_ids
              IF @cantidad = 0
              BEGIN
              INSERT INTO @Ret SELECT @ccs_ids
              RETURN
              END
              ELSE
              BEGIN
              INSERT INTO @Ret SELECT @ccs_ids
              DECLARE ListadoCcs CURSOR FOR ( SELECT ccs_id FROM
              CentroCosto WHERE ccs_ccs_id = @ccs_ids )
              OPEN ListadoCcs
              FETCH NEXT FROM ListadoCcs INTO @ccs_id
              WHILE @@FETCH_STATUS = 0
              BEGIN
              INSERT INTO
              @Ret
              SELECT
              a.ccs_id
              FROM
              dbo.fn_CentroCo sto(@ccs_id) As a
              >
              FETCH NEXT FROM ListadoCcs INTO @ccs_id
              END
              CLOSE ListadoCcs
              DEALLOCATE ListadoCcs
              END
              END
              ELSE
              BEGIN
              DECLARE ListadoCcs CURSOR FOR ( SELECT a.Value FROM
              dbo.fn_split(@c cs_ids,',') AS a )
              OPEN ListadoCcs
              FETCH NEXT FROM ListadoCcs INTO @ccs_id
              WHILE @@FETCH_STATUS = 0
              BEGIN
              INSERT INTO
              @Ret
              SELECT
              ccs_id
              FROM
              dbo.fn_CentroCo sto(@ccs_id)
              WHERE
              ccs_id not in (select ccs_id from
              @Ret)
              >
              FETCH NEXT FROM ListadoCcs INTO @ccs_id
              END
              >
              CLOSE ListadoCcs
              DEALLOCATE ListadoCcs
              END
              RETURN
              END
              go
              SET ANSI_NULLS OFF
              go
              SET QUOTED_IDENTIFI ER OFF
              go
              IF OBJECT_ID('dbo. fn_CentroCosto' ) IS NOT NULL
              PRINT '<<< CREATED FUNCTION dbo.fn_CentroCo sto >>>'
              ELSE
              PRINT '<<< FAILED CREATING FUNCTION dbo.fn_CentroCo sto >>>'
              go

              Comment

              • Andres Rormoser

                #8
                Re: SQL Server Performance Issue

                Dan,
                Sorry for the duplicate thread! The parallel thread is here:



                AR

                Comment

                Working...