Forum Replies Created

Viewing 15 posts - 1,321 through 1,335 (of 1,417 total)

  • RE: Multple If Statements with slow performance

    Try something like:

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_NULLS ON

    GO

    CREATE PROCEDURE dbo.s_Status_View

     @Status VARCHAR(10)

    AS

    SET NOCOUNT ON

    DECLARE @translate TABLE

    (

     Status VARCHAR(10) COLLATE DATABASE_DEFAULT NOT NULL PRIMARY KEY

     ,Order_Status INT NOT NULL

    )

    INSERT

  • RE: Error Trapping / Rollbacks

    Thinking about it, the second example will neither rollback nor commit. This means that when the session finishes, the INSERTs to the first table should be rolled back unless they...

  • RE: Error Trapping / Rollbacks

    I am not sure why you want to do an INSERT followed by an UPDATE, but your second example is always going to fail.

    To stop users changing your SPs you...

  • RE: Query items into correct order

    >> Object_ID not indicative of order of creation

    There seems to be nothing else to indicate the order of creation.

    Something like my query will produce the results in the order...

  • RE: Count record from different table

    @t is a TEST table.

    1. Take the query:

    -- The Query

    SELECT TID

     ,COUNT(DISTINCT TYPE) AS LOGON_TYPE_RECORD

     ,COUNT(CASE WHEN TYPE = 'JPJ' THEN 1 END) AS JPJ_RECORD

     ,COUNT(CASE WHEN TYPE = 'JPN' THEN 1 END)...

  • RE: Query items into correct order

    Assuming objectID indicates order of creation:

    SELECT O.objectID

     ,O.objectName

    FROM tblObject O

     LEFT JOIN (

      SELECT DISTINCT R.dependent_objectID

      FROM tblDependency R ) D

     ON O.objectID = D.dependent_objectID

    ORDER BY

     CASE WHEN D.dependent_objectID IS NULL

     THEN 0

     ELSE 1 END

     ,O.objectID

     

  • RE: Could not find database ID 104. Database may not be activated yet or may be in transition.

    In this type of query you need to ALIAS all tables and use the ALIAS with the columns. Also, in this instance, I can see no point in using a...

  • RE: Error Trapping / Rollbacks

    Interesting...

    With SQL2000:

    In Example A the batch actually fails to compile so the transaction does not even begin. This is what I would expect to happen.

    In Example B the batch does...

  • RE: Call stored Proc from a stored Proc

    Without knowing the details, it looks as though it will work.

    I would be inclined just to have an UPDATE statement rather than call the DELETE and INSERT SPs.

    If you want...

  • RE: Minimum values

    Similar to this thread:

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=145&messageid=315718

    You will need to use CASE to make zero return NULL.

    ps You may do better if the data is normalized.

     

  • RE: Views and Tables

    Do you mean SELECT?

    INSERT YourTable

    SELECT Col1, Col2, ...

    FROM YourView

     

  • RE: Loop

    There is probably a better way:

    -- Test data

    DECLARE @t TABLE

    (

     Seq INT not null

     ,RowID INT not null

     ,DataSample VARCHAR(20) COLLATE DATABASE_DEFAULT NOT NULL

    )

    INSERT @t

    SELECT 1, 1, '111111' UNION ALL

    SELECT 2, 2, 'A'...

  • RE: Two Users Pulling Same Account Problem

    Thanks for the feedback.

     

  • RE: Transaction Rollback and Committing

    If you REALLY have to:

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_NULLS ON

    GO

    CREATE PROCEDURE dbo.MyProc

    ( @EmployeeName VARCHAR(50)

     -- MONEY may be better for Sal, or at least DECIMAL(18,4)

     ,@Sal NUMERIC(18,2)

     ,@EmpID INT OUTPUT )

    AS

    SET NOCOUNT ON

    --SET...

  • RE: Transaction Rollback and Committing

    As you are not raising any special errors, why not keep it simple:

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_NULLS ON

    GO

    CREATE PROCEDURE dbo.MyProc

    ( @EmployeeName VARCHAR(50)

     -- MONEY may be better for Sal, or at...

Viewing 15 posts - 1,321 through 1,335 (of 1,417 total)