Forum Replies Created

Viewing 15 posts - 76 through 90 (of 356 total)

  • RE: Removing duplicate rows with IDs in two columns

    Is your #dup_problem table the output that you are trying to generate (without the "duplicate" rows of course), or does it match the structure of your source data table?

    If the...

  • RE: WHERE 1 = 1

    "WHERE (1 = 1)" is sometimes convenient when generating dynamic SQL.

    It avoids having to determine if a particular filter criterion in the WHERE clause is the first in the...

  • RE: Convert date field getdate() to "July 29" only

    Try:

    SELECT DATENAME(month, GETDATE()) + ' ' + DATENAME(day, GETDATE())

    This also works in different languages:

    SET LANGUAGE N'e???????' /* Greek */

    SELECT DATENAME(month, GETDATE()) + ' ' + DATENAME(day, GETDATE())

  • RE: Select an ID that matches data from mutiple rows

    Nevyn,

    Your query needs some fixing up to make it work. The left outer join is not having any filtering effect, so the query is just returning the Code for which...

  • RE: Select an ID that matches data from mutiple rows

    There are several ways of doing this, but here's an old-fashioned method.

    I've assumed your table definition looks something like this:

    CREATE TABLE Sequences (

    ID int NOT NULL PRIMARY...

  • RE: Get the missing time part from temp table.

    In which case this amendment should fulfill your requirements:

    SELECT TT.[Time] FROM TempTime TT

    WHERE NOT EXISTS (

    SELECT * FROM FlowTimesheet F1

    ...

  • RE: Get the missing time part from temp table.

    Given your test data, if I understand you correctly, there are only two contiguous time intervals in the 24-hour period where the Active flag was set (=1) between consecutive FlowTimesheet...

  • RE: Old SQL Syntax

    There's a relatively common pitfall that you can encounter when converting the old-style (*= / =*) outer join syntax to the LEFT / RIGHT OUTER JOIN syntax. This occurs when...

  • RE: Need to see if acustomer has visited the same store

    I don't think Jason's query will work.

    This might not either as I haven't tested it.

    ;WITH cteVisit AS (

    SELECT

    MemberID,

    ...

  • RE: t-sql nested xml with xml explicit mode

    OK, I've made the assumption that your table structure is something like the following:

    CREATE TABLE #TEST_FOR_XML (

    id int PRIMARY KEY,

    C_Comment varchar(100),

    i_number...

  • RE: t-sql nested xml with xml explicit mode

    Can you provide your source data table structure TEST_FOR_XML and some test data in a readily consumable form, i.e. as insert statements.

    Are you sure you need the CDATA section? If...

  • RE: to get the number of counts

    My query gives the following results, where the single entry for CID=1001 returns the visit date 2009-03-03 rather than 2009-02-23, but I believe that it returns what you want.

    CID ...

  • RE: to get the number of counts

    Thanks for supplying the test data. However, your expected results seem to be slightly inconsistent with your described requirements. Is it the first or the second date of a pair...

  • RE: Trying to not use Cursors - Eliminating Duplicates

    If I understand your cursor code correctly, then the following 2 statements will do the equivalent. The self join on the ll_dup_sender table is effectvely creating a map linking duplicate...

  • RE: Determine if a date is a Friday

    The trouble with DATEPART is that it depends on the value of @@DATEFIRST.

    The value of this expression:

    DATEDIFF(day, '17530101', @TestDate) % 7 + 1

    will always be 5 if the value of...

Viewing 15 posts - 76 through 90 (of 356 total)