Forum Replies Created

Viewing 15 posts - 3,031 through 3,045 (of 10,144 total)

  • RE: Assign Row number to the result set without using Row_Number

    Koen Verbeeck (8/15/2014)


    GilaMonster (8/15/2014)


    Eirikur Eiriksson (8/14/2014)


    You can try out these methods as previously suggested

    However OP said

    I really don't like this temp table creation

    So, no row number, no temp tables....

  • RE: Display ALL rows even if no data exists

    Thanks Steve. Something along these lines then. Not sure where two of the tables (MG_COUNTRY,MG_OFFICE) fit into this but it's worth a try:

    SELECT *

    INTO #Offices

    FROM (VALUES

    ('KBE ANR','BELGIUM'),('KBE ZEE','BELGIUM'),('KEU...

  • RE: Are the posted questions getting worse?

    TomThomson (8/14/2014)


    ChrisM@Work (8/14/2014)


    A little further south in the Thames Valley, this is the best summer we've had for six or seven years.

    The same here - Cheshire is not famous...

  • RE: Display ALL rows even if no data exists

    This is worth a try:

    SELECT *

    INTO #Offices

    FROM (VALUES

    ('KBE ANR','BELGIUM'),('KBE ZEE','BELGIUM'),('KEU ANR','BELGIUM'),

    ('KDE VIE','AUSTRIA'),

    ('KDE BRE','GERMANY'),('KDE BRV','GERMANY'),('KDE DUS','GERMANY'),('KDE FRA','GERMANY'),('KDE HAM','GERMANY'),('KDE MUC','GERMANY'),('KDE STR','GERMANY'),

    ('KFR BOD','FRANCE'),('KFR DKK','FRANCE'),('KFR FOS','FRANCE'),('KFR LEH','FRANCE'),('KFR LIO','FRANCE'),('KFR MRS','FRANCE'),

    ('KFR PAR','FRANCE'),('EXAF PARIS','FRANCE'),('FRBAL BOD','FRANCE'),('KEU...

  • RE: Query help please

    ;WITH Dates AS (

    SELECT [date]

    FROM (VALUES

    (GETDATE()-7.7),(GETDATE()-6.6),(GETDATE()-5.5),(GETDATE()-4.4),(GETDATE()-3.3),

    (GETDATE()-2.2),(GETDATE()-1.1),(GETDATE()-0),(GETDATE()+1.1),(GETDATE()+2.2),

    (GETDATE()+3.3),(GETDATE()+4.4),(GETDATE()+5.5),(GETDATE()+6.6),(GETDATE()+7.7)

    ) d ([date])

    )

    SELECT

    [date],

    [Dayname] = DATENAME(dw, [date]),

    LatestSunday = DATEADD(DAY,-1+DATEDIFF(DAY,-1,[date])/7*7,0),

    LatestMonday = DATEADD(DAY,DATEDIFF(DAY,0,[date])/7*7,0),

    LatestTuesday = DATEADD(DAY,1+DATEDIFF(DAY,1,[date])/7*7,0)

    FROM Dates

  • RE: Help with query !!!

    Shadab Shah (8/6/2014)


    Thanks Chris for the reply and your time.

    Since yesterday i am trying to improvised on the solution given by you.

    Actually there is one more condition , Consider the...

  • RE: Are the posted questions getting worse?

    TomThomson (8/13/2014)


    GilaMonster (8/13/2014)


    TomThomson (8/13/2014)


    GilaMonster (8/12/2014)


    I'd love some rain. It's getting towards the end of winter here and it is soooo dry.

    I wish I could give you some of ours. ...

  • RE: Display ALL rows even if no data exists

    pwalter83 (8/13/2014)


    ChrisM@home (8/8/2014)


    pwalter83 (8/8/2014)


    ChrisM@Work (8/7/2014)


    I don't see any parameters in your code, Paul.

    Any ideas, Chris ??[/quote

    Hi Paul, I'm on break in Normandy with no access to SQL Server until tuesday....

  • RE: Accurate Time between Two Dates in Year, Month,Day Format

    Vimal Lohani (8/13/2014)


    Thanks ChrisM@Work for your comment. I got the tone.

    Generally UDFs are slow as compare to same query.

    You may also wish to correct the error. Your function returns...

  • RE: joining 2 selects where a value not in Values

    Phil Parkin (8/13/2014)


    Alan.B (8/12/2014)


    If I understand your question correctly you need to do what is referred to as a Left Anti Join Semi Join.

    Not by me! Or anyone else,...

  • RE: Accurate Time between Two Dates in Year, Month,Day Format

    -- Your function returns incorrect values when the time of the from-date is later than the time of the to-date.

    -- Also, it's likely to be far faster written as an...

  • RE: Struggling on Duplicates while Join Three Table Produce

    SELECT

    e1.Place,

    e1.Objective,

    e1.[Year],

    e1.[Month],

    e1.Exam1,

    e2.Exam2,

    e3.Exam3

    FROM #tmpExam1 e1

    LEFT JOIN #tmpExam2 e2

    ON e2.Place = e1.Place

    AND e2.[Year] = e1.[Year]

    AND e2.Objective = e1.Objective

    AND e2.[Month] = e2.[Month]

    INNER JOIN #tmpExam3 e3

    ON e3.Place...

  • RE: Tuning a query that takes 60 minutes to run,

    rajsin7786 (8/11/2014)


    Hi guys,

    thanks for all your help, i have updated statistics on all the columns, I ran the query suggested by ChrisM and also the original query , both...

  • RE: SELECT clause

    ScottPletcher (8/7/2014)


    ChrisM@Work (8/7/2014)


    gstarsaini (8/7/2014)


    Thanks for the reply.

    This means there is no effect on the queries?

    Each reply posted to your question implies "maybe", "probably" or "definitely". The average of these isn't...

  • RE: Display ALL rows even if no data exists

    I don't see any parameters in your code, Paul.

Viewing 15 posts - 3,031 through 3,045 (of 10,144 total)