Forum Replies Created

Viewing 15 posts - 1,171 through 1,185 (of 1,491 total)

  • RE: Unique Field

    DECLARE @t TABLE

    (

        PersonID int NOT NULL

        ,FirstName varchar(20) NOT NULL

        ,Surname varchar(20) NOT NULL

        ,Added datetime NOT NULL

    )

    INSERT INTO @t

    SELECT 1234, 'John', 'Doe', '20071201 14:00' UNION ALL

    SELECT 1234, 'John', 'Doe', '20071201 13:00' UNION...

  • RE: Joins difference

    In the case of a LEFT JOIN an INNER JOIN is done first, then any rows in the left table not in the result set are added with NULLs in...

  • RE: Joins difference

    If ROLEID is in glb_Item_Rights then you should put it into the ON clause of the join otherwise ROLEIDs of NULL will be removed when ROLEID = 11 is evaluated...

  • RE: row count

    Try:

    IF EXISTS (

        SELECT *

        FROM Indicator I

        WHERE EXISTS (

            SELECT *

            FROM jobs J

            WHERE J.jobid = I.jobid

                AND EXISTS (

                    SELECT *

                    FROM OPENXML (@empDdoc, '/emps/Item', 1) WITH (ChangeToemp int, emp int) AS X

                    WHERE X.emp =...

  • RE: join

    SELECT e.empID, empName, lc.CountyName

    FROM emp e

        JOIN (

                SELECT oc.empid

                    -- You have to decide which county you want.

                    -- Just taking the lowest ID here

                    ,MIN(oc.countyid) AS countyid

                FROM OfficeCounty oc

                GROUP BY oc.empid

            ) D

            ON...

  • RE: importing data from excel

    Try converting to bigint first.

    SELECT CAST(CAST(9.37123e+009 AS bigint) AS nvarchar(50))

     

  • RE: How to delete a local temp table

    IF OBJECT_ID('tempdb..#TableExist') IS NOT NULL

        TRUNCATE TABLE #TableExist

  • RE: Creating indexed view problem.

    I am not sure what "where exp_dt like '%9999%'" means but I suspect it is causing the problem.

    If you are looking for dummy dates in the year 9999, try WHERE...

  • RE: Unique constraint that ignores nulls

    Two common ways of achieving this are:

    1. Indexed View

    Create a View which includes WHERE UserName IS NOT NULL and put an unique index on the view.

    2. Calculated Column

    Create a calculated...

  • RE: QUery

    Assuming e.empid should be o.empid, try something like the following:

    IF EXISTS (

            SELECT *

            FROM tblemp o1

            WHERE EXISTS (

                    SELECT *

                    FROM indicator I1

                    WHERE o1.empid=I1.empid

                        AND I1.userroleid=4

                )

                AND EXISTS (

                    SELECT *

                    FROM OPENXML (@empIDdoc, '/emps/Item', 1) WITH(ChangeToemp...

  • RE: Blackberrys

    Blackberries have a utility to synch them to Outlook so we synch SQL to Outlook using the Outlook object model. To speed up the process we keep shadow tables of...

  • RE: How do I SELECT a column that STRICTLY matches a list

    or:

    SELECT RoomType

    FROM MyTable T

        JOIN (

            SELECT 1 UNION ALL

            SELECT 2 UNION ALL

            SELECT 4

        ) D (Amenity)

        ON T.Amenity = D.Amenity

    GROUP BY RoomType

    HAVING COUNT(*) = 3

     

  • RE: Format String

    As you have seen, manipulating strings is best done on the client or middle tier. If you really must do this in SQL then the following may be slightly more...

  • RE: simplifying query

    Something like the following may help:

    SELECT DISTINCT

        n.cust_id

        ,es.er_id

        ,n.name_id

        ,n.first_name

        ,n.mid_name

        ,n.last_name

        ,n.name_gen

        ,es.cust_id as conflict_cust_id

    FROM [name] n

        JOIN er_cust_state es

            ON n.dsrc_acct_id = es.dsrc_acct_id

        JOIN (

                SELECT es2.cust_id, es2.er_id, MAX(n2.name_id) AS name_id

                FROM [name] n2

                    JOIN er_cust_state es2

                        ON n2.dsrc_acct_id = es2.dsrc_acct_id

                    LEFT JOIN...

Viewing 15 posts - 1,171 through 1,185 (of 1,491 total)