Forum Replies Created

Viewing 15 posts - 1,201 through 1,215 (of 1,491 total)

  • RE: WHERE Clause vs. JOIN Clause

    This query JOINS tbl_Order to tbl_Agreement ON O.OrderNo = A.OrderNo AND O.Type < 3.

    The FULL JOIN then adds the rows from tbl_Order and tbl_Agreement which were not included in the...

  • RE: locking hints

    This is a basic outline:

    Locks in SQL are only held for the duration of a transaction. If you do not define your own transactions, each command is its own transaction....

  • RE: cannot get over this deadlock..

    In SP2, assuming the same filter condition for the SELECT and UPDATE of table1, is it possible that new rows can be added to table1 between the time of the...

  • RE: Rewrite SQL with ANSI for 2005- HELP!!

    or:

    SELECT P1.MAIN_CODE

         ,P1.SUB_CODE

        ,P1.[NAME]

        ,P2.INTVALUE AS Days

    FROM pinf P1

        LEFT JOIN pinf P2

            ON P1.MAIN_CODE = P2.MAIN_CODE

                AND P1.SUB_CODE = P2.SUB_CODE

                AND P2.[NAME] = 'DAYS'

    WHERE P1.MAIN_CODE = 'RET'

        AND P1.[NAME] <> 'ENDS'

    [Edit] Sorry Sean, you had already...

  • RE: Stop execution when the error occur in EXEC (SQL statement)

    In SQL2000, you need to monitor @@ERROR after each statement. With your example, in testUnique do something like:

    EXEC (@strSQLExec)

    RETURN(@@ERROR)

    and in launchtestUnique do something like:

    DECLARE @Err int

    EXEC @Err =...

  • RE: Really stuck with an SQL query

    Maybe:

    DECLARE @TenantID int

    SET @TenantID = 1 -- ID for Tenant

    SELECT B.*

    FROM Building B

        JOIN (

                SELECT BA1.BuildingID, COUNT(*) AS MatchingAttributes

                FROM Requirements R1

                    JOIN BuildingAttribute BA1

                        ON R1.AttributeID = BA1.AttributeID

                            AND R1.TenantID = @TenantID

                GROUP BY...

  • RE: Help needed w/query

    I would be interested in knowing how well something like the following works:

    -- *** Test Data ***

    CREATE TABLE #YourTable

    (

        StartTime datetime NOT NULL

        ,EndTime datetime NULL

    )

    GO

    INSERT INTO #YourTable

    SELECT '20070419 08:32', NULL UNION...

  • RE: Simple Query

    SELECT *

    FROM RSAccouts A

    WHERE A.Level1Account = (

            SELECT A1.Level1Account

            FROM RSAccouts A1

            WHERE A1.AccountCode = '000009'

        )

     

  • RE: parameter to derived table

    Obviously you will have to join to Table1 outside of the derived table as well. Something like:

    SELECT T1.*, T2.*

    FROM Table1 T1

        JOIN Table2 T2

            ON T1.col1 = T2.col1

        JOIN (

                SELECT T4.col1, MAX(T4.colDate) AS...

  • RE: parameter to derived table

    Derived tables can be regarded as inline views so you cannot pass parameters. Something like the following should work:

    SELECT T.col1, T.colDate, T.col3

    FROM Table2 T

        JOIN (

                SELECT T2.col1, MAX(T2.colDate) AS maxDate

                FROM Table1...

  • RE: Handling a malformed CSV file

    The quick method of doing this from the command prompt is:

    echo.>>YourFile.csv

    You could put this in a batch file.

     

  • RE: Return next available product value

    Maybe:

    SELECT MIN(ProductCode)

    FROM YourTable

    WHERE ProductCode >= '12'

     

  • RE: Is there a way to output table variable from a dynamice SQL?

    If you need dynamic SQL, you can insert the results into a temp table. eg:

    CREATE TABLE #Multi

    (

        Attribute varchar(100) NOT NULL

    )

    INSERT INTO #Multi

    EXEC ('SELECT attribute FROM dbo.Staging WHERE CHARINDEX('','', attribute) >...

  • RE: Is there a way to output table variable from a dynamice SQL?

    A table variable cannot be used as a parameter. (Also, it seems to be defined as @tMulti not @Multi.)

    I see no point with dynamic SQL here. Why not just:

    DECLARE @Multi...

Viewing 15 posts - 1,201 through 1,215 (of 1,491 total)