Forum Replies Created

Viewing 15 posts - 1,261 through 1,275 (of 1,491 total)

  • RE: rtnval not working?

    You will need to return an OUTPUT parameter.

    The SP should look something like:

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_NULLS ON

    GO

    CREATE  PROCEDURE dbo.spCDI_Add_New_CDI_Data

        @sTelenumber varchar(100)

        ,@sDate smalldatetime

        ,@sTime varchar(20)

        ,@sRings varchar(20)

        ,@scallrecieved datetime

        ,@sName varchar(2000) OUTPUT

    AS

    SET NOCOUNT ON

    SELECT...

  • RE: Difference in query plan with use of COALESCE

    Viking,

    Does:

    SELECT BPE.BusnPartEmpId

    FROM dbo.tblBusnPartEmp AS BPE WITH (NOLOCK)

        INNER LOOP JOIN dbo.tblDivBranchBusnPartEmp AS DBBPE WITH (NOLOCK)

            ON BPE.BusnPartEmpId =DBBPE.BusnPartEmpId

        INNER JOIN dbo.tblDivBranch AS TDB WITH (NOLOCK)

            ON TDB.DivBranchId = DBBPE.DivBranchId

    WHERE...

  • RE: Difference in query plan with use of COALESCE

    COALESCE seems to have some effect. No one had time to work out what in the following thread:

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=323566#bm325392

    A quick look at the query plan suggests that the COALESCE is...

  • RE: Trying to get one aggregate set from two different tables

    Do the UNION ALL in a derived table. Something like:

    SELECT CarrierName

        ,COUNT(*) AS Total

    FROM (

            SELECT CarrierName

            FROM PreviousCarrierForWC

            UNION ALL

            SELECT txtPriorCarrier

            FROM PreviousCarrierForBA

        ) D

    GROUP BY CarrierName

     

  • RE: Pivot type query

    If the Players table does not change much, you may want to hard code like:

    SELECT MAX(CASE PlayersID WHEN 1 THEN [Description] END) AS Team

        ,MAX(CASE PlayersID WHEN 2 THEN [Description] END)...

  • RE: Retrieving info

    SELECT ER.*

    FROM employee_rates ER

        LEFT JOIN employee E

            ON ER.employeeID = E.employeeID

                AND ER.emprate = E.emprate

    WHERE E.employeeID IS NULL

    or

    SELECT *

    FROM employee_rates ER

    WHERE NOT EXISTS (

            SELECT *

            FROM employee E

            WHERE E.employeeID = ER.employeeID

                AND E.emprate =...

  • RE: Historical Data

    If you have less than about 10000 rows a triangular join, like the following, should be reasonably efficient.

    If you have more than 10000 rows you will have to look at...

  • RE: Merging rows in a table

    An index on [Date], Incident should help with the speed.

     

  • RE: TSQL Faster Than Stored Procedure?

    Two more thoughts for the view:

    1. If you have indexes on the Foreign Keys, you could try explicitly using INNER MERGE JOIN instead of INNER JOIN.

    2. I tend to avoid...

  • RE: Merging rows in a table

    This assumes comments will never exceed 8000 characters.

    -- *** Test Data ***

    CREATE TABLE dbo.YourTable

    (

        [Date] datetime NOT NULL

        ,Incident int NOT NULL

        ,Comments varchar(100) NOT NULL

    )

    GO

    INSERT INTO dbo.YourTable

    SELECT '20070228', 1, 'c1' UNION ALL

    SELECT...

  • RE: Update Null values

    As your primary key has some meaning you can get away with something like:

    -- *** Test Data ***

    DECLARE @t TABLE

    (

        Code varchar(5) NOT NULL PRIMARY KEY

        ,Prov varchar(25) NULL

    )

    INSERT INTO @t

    SELECT 'BE31',...

  • RE: Datetime imprecision

    This is all in BOL.

    Smalldatetime is rounded to the nearest minute.

    Milliseconds in datetime are rounded to 0, 3 or 7.

     

  • RE: TSQL Faster Than Stored Procedure?

    Sorry, that exhausts my suggestions.

     

  • RE: TSQL Faster Than Stored Procedure?

    @NetworkId should be varchar(255) to avoid datatype precedence issues.

    Putting order into a view is not a good idea. Try removing the TOP 100 PERCENT and ORDER BY from the view....

Viewing 15 posts - 1,261 through 1,275 (of 1,491 total)