Forum Replies Created

Viewing 15 posts - 4,006 through 4,020 (of 7,597 total)

  • RE: Query to join three tables but filter out subset of the data

    CELKO (12/13/2016)

    Obviously in a real schema, the identifier of an employee would be some sort of industry-standard encoding (Social Security number in the United States, social insurance number in Canada,...

  • RE: Bitwise & NULL

    I see some strong advantages to the combined-bits approach.

    To distinguish NULL values, I think you'd need another column of the same int type, with bits in it to indicate NULL...

  • RE: Data update

    You still don't need to cast the column, so why get into that bad habit? Yes, SQL corrects it in this case (at least for now?!). Why not...

  • RE: trying to get rid of clustered index scan

    Create the index below. Uncomment anything you can:

    CREATE /*UNIQUE*/ NONCLUSTERED INDEX AdminObservation__IX_TherapyAdmin_ID

    ON hcs.AdminObservation ( TherapyAdmin_ID )

    INCLUDE ( VisitObservation_ID )

    ...

  • RE: Need help with querying dates and times

    ...

    WHERE datetime_column >= @StartDate_set_to_0800_AM AND

    datetime_column < DATEADD(DAY, 1, @EndDate_set_to_midnight) AND

    DATEPART(HOUR, datetime_column) BETWEEN 8 AND 16

  • RE: Kill SPIDs through automated job(while restore)

    Personally I've had much lesser delays/stalls using this command:

    ALTER DATABASE SQLTRIX SET OFFLINE WITH ROLLBACK_IMMEDIATE;

    And you can get into devilish issues with "SINGLE_USER". You need to make sure you...

  • RE: Last 2 years and YTD

    Double oops, you're right. I made sure, too, that I went back to Jan 1 00:00 to get the full year.

  • RE: Last 2 years and YTD

    Oops, right, YEAR - 3 not YEAR - 2.

  • Reply To: DDL event for job changes

    I'd urge you not to create triggers on system tables, particularly job tables.

    The sysjobs table does have a "date_modified" column. Presumably that column is updated whenever any step within that...

  • RE: Move DB file with a '.' in the name

    Hmm, not sure. That file name should be allowed.

    Verify again that the filename is correct:

    USE <your_db_name>

    EXEC sp_helpfile

    The first column of the output will contain the logical file names.

  • RE: Check default constraint for 2 columns

    No, it isn't.

    First, the first constraint name in the EXISTS is not the same as the first one in the code.

    Second, you really need to check for, and create, these...

  • RE: Last 2 years and YTD

    Something like this should do it:

    SELECT

    SUM(CASE WHEN YEAR(Invoice_date) = YEAR(curr_year_jan_01) - 2 THEN amount ELSE 0 END) AS Total_2_Years_Ago,

    SUM(CASE WHEN YEAR(Invoice_date) =...

  • RE: Clustered Index on datetimeoffset?

    When a user wants to search for something in that log they almost always use a filter on the Created column. ...

    * Clustured Index is a good choice when dealing...

  • RE: Find unique NULL records from data set

    This should be more efficient:

    SELECT VisitID

    FROM #Test

    GROUP BY VisitID

    HAVING MAX(CASE WHEN IsPrimaryCareProvider ='Y' THEN 1 ELSE 0 END) = 0

  • RE: ROW_NUMBER to distinguish between identical records

    First, the Project table should be keyed on ( DomainID, SchoolID, ID ), if, as your example query implies, Domain is the more dominant "parent" relation. Reverse the first two...

Viewing 15 posts - 4,006 through 4,020 (of 7,597 total)