Forum Replies Created

Viewing 15 posts - 766 through 780 (of 1,494 total)

  • RE: Help writing a SQL - to capture counts

    SELECT SUM(1 & IND1) AS IND1

    ,SUM(1 & IND1 & IND2) AS IND2

    ,SUM(1 & IND1 & IND2 & IND3) AS IND3

    -- etc

    FROM ALL_INDS

  • RE: Flawed Trigger in SQL 2005

    There could be both inserts and updates:

    SET ANSI_NULLS, QUOTED_IDENTIFIER ON

    GO

    ALTER TRIGGER [dbo].[Update2ndTable]

    ON [dbo].[Table1]

    AFTER INSERT, UPDATE

    AS

    SET NOCOUNT ON

    UPDATE T2

    SET EmailAddr = I.EmailAddr

    ,Folder = RTRIM(UploadPath) + '\' + RTRIM(UserName)+ '\Downloads'

    FROM [dbo].[Table2]...

  • RE: Update statement returns different results each time it runs

    Without some sample data and DDL it is difficult to say.

    You need to do something to ensure that only a one to one relationship exists.

  • RE: Update statement returns different results each time it runs

    This is the problem when using UPDATE with a JOIN.

    You have to ensure there is only a one to one relationship between the two tables. If there is a one...

  • RE: Trigger Help??

    SET ANSI_NULLS, QUOTED_IDENTIFIER ON

    GO

    CREATE TRIGGER dbo.TI_TransactionTable

    ON dbo.TransactionTable

    AFTER INSERT

    AS

    SET NOCOUNT ON

    UPDATE dbo.TargetTable

    SET StatusFlag = ' '

    WHERE StatusFlag <> ' '

    AND EXISTS

    (

    SELECT *

    FROM inserted I

    WHERE I.LotJob = dbo.TargetTable.LotNumber

    AND I.TrnQuantity = dbo.TargetTable.ReceiptQty

    AND...

  • RE: Variable field length join

    -- either (LEN ignores trailing spaces)

    LEFT(vm.VCTCollectZipcodeId, LEN(vhml.ZipcodeFrom)) = vhml.ZipcodeFrom

    -- or

    vm.VCTCollectZipcodeId LIKE vhml.ZipcodeFrom + '%'

  • RE: Learning MDX

    There are some MDX articles in the Stairways menu, above Forums, on SSC.

  • RE: Searching and selecting a recurring string from within a variable length field

    Obviously you have to use the PATINDEX to do the SUBSTRING:

    -- *** Test Data ***

    CREATE TABLE #t

    (

    Grade varchar(8000) NULL

    )

    INSERT INTO #t

    SELECT 'R1 - Background, M0 - No Maculopathy'

    UNION ALL SELECT...

  • RE: Delete results from select statement

    DELETE dbo.Table_2

    WHERE EXISTS

    (

    SELECT *

    FROM dbo.Table_1 T1

    WHERE T1.[UNIQUE #] = Table_2.[UNIQUE #]

    AND T1.[SEQ ORDER #] = Table_2.[SEQ ORDER #]

    )

  • RE: instances one or more

    We run separate instances for thrid party products where they insist that they need sysadmin rights to the instance in order to provide support.

    We tend to run all our internally...

  • RE: Trying to avoid cursor

    ;WITH Grp

    AS

    (

    SELECT *

    ,ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY trans_time)

    - ROW_NUMBER() OVER (PARTITION BY user_id, trans_type ORDER BY trans_time) AS Grp

    FROM dbo.user_trans

    )

    ,GrpNoDups

    AS

    (

    SELECT user_id, trans_type, grp

    ,MIN(trans_time) AS trans_time

    FROM Grp

    GROUP BY user_id,...

  • RE: delete help using output.deleted option in sql

    I suspect SalesHeader has a foreign key to Contact. Try:

    DELETE SalesHeader WHERE ContactId = 10

    DELETE Contact WHERE ContactId = 10

  • RE: Ranking question

    -- *** Test Data ***

    CREATE TABLE #t

    (

    Col1 char(1) NOT NULL

    ,Col2 int NOT NULL

    )

    INSERT INTO #t

    SELECT 'A', 1

    UNION ALL SELECT 'A', 2

    UNION ALL SELECT 'A', 3

    UNION ALL SELECT 'B', 4

    UNION ALL...

  • RE: restore from file

    I cannot remember if SQL2000 gave a specific exception if you tried to restore a backup produced by a more recent version of SQL server.

    It may be worth finding out...

  • RE: Data Quality

    As sometimes excessive data validation can cause users not to enter anything, another approach is to produce regular data quality reports grouped by department, user etc.

    If management want information based...

Viewing 15 posts - 766 through 780 (of 1,494 total)