Forum Replies Created

Viewing 15 posts - 316 through 330 (of 844 total)

  • RE: I need help with SQL queries

    Try this:
    declare @StartDate date = '01-01-2018',
        @EndDate date = '09-30-2018'
    ;

    SELECT C.No_ AS [No_],
        C.Name, C.Spcode, C.Address, C.City, C.[PostCode], C.County, D.dcValue
    INTO...

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: I need help with SQL queries

    rjp123 - Wednesday, October 3, 2018 1:56 PM

    rjp123 - Wednesday, October 3, 2018 1:55 PM

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: I need help with SQL queries

    If I know for sure the date field does NOT carry any time values then I agree with using the between.  But if it has time, you could miss records. ...

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: insert the records in Table 2 whenever the records delete in Table 1.

    Jeff Moden - Monday, October 1, 2018 9:02 AM

    Exactly.

    I can see your points.  But as with many things in SQL I...

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: I need help with SQL queries

    Just added a few tweaks:
    DECLARE @StartDate DATE;
    DECLARE @EndDate DATE;
    DECLARE @PrevYearStart DATE;
    DECLARE @PrevYTDEnd DATE;
    DECLARE @MonthStart DATE;

    SET @StartDate = '01-01-2018';
    SET @EndDate =...

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: I need help with SQL queries

    Looks like you got the YTD numbers.  Use the DATEADD to determine your Previous year start and end dates, same for month to date.

    Start by writing these as...

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: Need syntax help with a JOIN inside of a Subquery

    You have a comma after Facility, that is what is casing the error.

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: Today's Random Word!

    jasona.work - Tuesday, October 2, 2018 7:27 AM

    Jason A. Long - Tuesday, October 2, 2018 7:18 AM

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: insert the records in Table 2 whenever the records delete in Table 1.

    Jeff Moden - Monday, October 1, 2018 8:04 AM

    That'll work but, if you ever need to disable that particular functionality (especially temporarily),...

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: Talking baseball

    below86 - Friday, September 14, 2018 8:46 AM

    I knew it was to good to be true.  How do you make trades...

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: insert the records in Table 2 whenever the records delete in Table 1.

    If you are running a DELETE SQL statement you could use the OUTPUT statement to write the rows deleted to another table.
    https://msdn.microsoft.com/en-us/library/ms177564.aspx

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: SQL Tuning help is appriciated

    What part is taking the most time?  Can you split it up to see?
    Try replacing the first SQL with something like this:

    SET @prep_date_start = COALESCE(@prep_date_start,...

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: Today's Random Word!

    DesNorton - Thursday, September 27, 2018 8:35 AM

    ZZartin - Thursday, September 27, 2018 8:33 AM

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: Today's Random Word!

    DesNorton - Wednesday, September 26, 2018 7:51 AM

    ZZartin - Wednesday, September 26, 2018 7:42 AM

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

  • RE: Today's Random Word!

    ManicStar - Monday, September 24, 2018 12:05 PM

    Cheddar

    Provolone

    -------------------------------------------------------------
    we travel not to escape life but for life not to escape us
    Don't fear failure, fear regret.

Viewing 15 posts - 316 through 330 (of 844 total)