Forum Replies Created

Viewing 15 posts - 5,986 through 6,000 (of 6,036 total)

  • RE: Group By Week

    result_date - DATEPART (dw, result_date) + 1

    This is made for @@DATEFIRST = 1 (Monday is first day of the week)

    Check your server settings.

    _____________
    Code for TallyGenerator

  • RE: Group By Week

    groub by DATEDIFF(ww, result_date, getdate())

    getdate() may be replaced with any given date. For example, '1900-01-01 00:00'.

    Anyway difference in weeks between that date and dates for all same week tasks will...

    _____________
    Code for TallyGenerator

  • RE: Top value

    I forgot to change alias in GROUP BY for nested query.

    This must work:

    SELECT MAX(l.clrec_sysid), l.cons_entity_id, lm.Max_event_date

    FROM tblclinical_record_master l

    INNER JOIN tblcase c ON l.case_sysid = c.case_sysid

    INNER JOIN (SELECT l1.cons_entity_id,MAX(l1.event_date) as Max_event_date

    FROM...

    _____________
    Code for TallyGenerator

  • RE: Help in UPDATE

    If createddttm is datetime then it is not in any format.

    Format is used only for date representation.

    The strict rule is:

    Put clustered index on the column you most often use...

    _____________
    Code for TallyGenerator

  • RE: sortorder on varchar datatype column containing numeric values

    Lets say that your column data type is varchar(50).

    In such case it gonna be:

    ORDER BY case when ISNUMERIC(ColumnName) = 1 then REPLICATE ('0', 50 - LEN(LTRIM(ColumnName))) + LTRIM(ColumnName) else ColumnName...

    _____________
    Code for TallyGenerator

  • RE: Query

    DECLARE @Query varchar(8000), @DBName varchar(20)

    SET @DBName = 'A' -- or 'B' or 'C', it should be parameter for your SP

    SET @Query = 'SELECT DISTINCT K.MAXCOM_ID FROM ' + @DBName +...

    _____________
    Code for TallyGenerator

  • RE: Help in UPDATE

    Column doc.CreatedDtTm participates in multiple joins "between ... and ..."

    Is there clustered index on this column? It should be.

    _____________
    Code for TallyGenerator

  • RE: Top value

    SELECT MAX(l.clrec_sysid), l.cons_entity_id, lm.Max_event_date

    FROM tblclinical_record_master l

    INNER JOIN tblcase c ON l.case_sysid = c.case_sysid

    INNER JOIN (SELECT l1.cons_entity_id,MAX(l1.event_date) as Max_event_date

    FROM tblclinical_record_master l1

    GROUP BY l.cons_entity_id) lm on l.cons_entity_id = lm.cons_entity_id

    and l.event_date = Max_event_date

    WHERE...

    _____________
    Code for TallyGenerator

  • RE: Column Naming Conventions (rears it''''s ugly head again :)

    I don't remember now where I've read it. It was not only source.

    But I know that optimizer takes column name from query and searches all tables mentioned in the query...

    _____________
    Code for TallyGenerator

  • RE: need help to delear time

    Strange error.

    Probably you forgot about quotes.

    declare @StartTime dateTime

    set @StartTime = '20:30'

    works absolutely fine.

    _____________
    Code for TallyGenerator

  • RE: Column Naming Conventions (rears it''''s ugly head again :)

    Using table name in column name does not make any sence.

    If you want to which table this column belongs to you can write TableName.ColumnName instead of TableNameColumnName.

    First option makes optimizer...

    _____________
    Code for TallyGenerator

  • RE: Disappearing Tables

    INSTEAD OF DELETE trigger is good idea.

    You can also create dummy table with FK relation to PK of your table. This will block any attempt to delete rows from the...

    _____________
    Code for TallyGenerator

  • RE: trigger on view

    Freaky Dutch English...

    But if you have any SELECT statement in your application???

    Dynamic SQL is your choice???

    I've forgotten somebody uses access data by "SELECT...

    _____________
    Code for TallyGenerator

  • RE: find difference between dates - help~~

    Try this:

    select DT.Thedate, DT.Value, DT.Value - T3.Value as Delta

    FROM  (Select t1.thedate, T1.Value, max(t2.thedate) as PrevDate

               from MyTable T1

               left join MyTable T2 on t1.thedate > t2.thedate

               group by t1.thedate, T1.Value)...

    _____________
    Code for TallyGenerator

  • RE: trigger on view

    It's absolutely natural to create INSTEAD OF trigger on a view.

    This trigger suppose to contain set of statements taking data from view fields and put it into source tables.

    Query Analizer...

    _____________
    Code for TallyGenerator

Viewing 15 posts - 5,986 through 6,000 (of 6,036 total)