Forum Replies Created

Viewing 15 posts - 1,396 through 1,410 (of 1,490 total)

  • 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...

  • RE: Min value across columns

    Something like the following should be more efficient as the table will only be scanned once:

    -- Test Data

    DECLARE @t TABLE

    (

     TID INT NOT NULL PRIMARY KEY

     ,TDate1 DATETIME NULL

     ,TDate2 DATETIME NULL

     ,TDate3 DATETIME...

  • RE: UDF as Default Attribute Value

    In SQL2000, I do not think defaults are allowed to refer to other columns in the table.

    You may be able to get away with this in SQL2005.

     

  • RE: Count record from different table

    -- Test Data

    DECLARE @t TABLE

    (

     TID CHAR(5) COLLATE DATABASE_DEFAULT NOT NULL

     ,TYPE CHAR(3) COLLATE DATABASE_DEFAULT NOT NULL

    )

    INSERT @t

    SELECT 'KL202', 'JPJ' UNION ALL

    SELECT 'KL202', 'JPJ' UNION ALL

    SELECT 'KL202', 'JPN' UNION ALL

    SELECT 'KL202', 'JIM'...

Viewing 15 posts - 1,396 through 1,410 (of 1,490 total)