Forum Replies Created

Viewing 15 posts - 5,596 through 5,610 (of 6,036 total)

  • RE: How to check that remote server is accessible

    That's a problem.

    Server may exist, and be accessible from application, but not accessible from the server where SP is trying to create the view. For example, because of Firewall settings.

    That's...

  • RE: Number of Mondays between two dates

    My query does not depend on DATEFIRST settings.

  • RE: Number of Mondays between two dates

    I mean get (-1)%7, not get (-1)/7

    And what you expect to get when 2 dates are the same?

    There are no Mondays between them, so it must be 0.

    What's wrong with...

  • RE: Number of Mondays between two dates

    There is no way to get (-1)%7 in my formula.

    Both @@Datefirst and Datepart(dw,@endDate) are positive values, their SUM is >= 2.

    And for both dtes '2005-12-31' it returns 0 which...

  • RE: Number of Mondays between two dates

    OK.

    @EndDate - (@@Datefirst+Datepart(dw,@EndDate)-2) %7

    gives you last Monday before @EndDate.

    Datediff(dd, @StartDate, @EndDate - (@@Datefirst+Datepart(dw,@EndDate)-2) %7) / 7

    gives you result.

    The only thing you need to adjust is number of Mondays between 2...

  • RE: help needed with a set based update

    Can you make an estimation how long it will take to run a cursor over 20 million rows firing trigger doing update with derived table on the same table with...

  • RE: How to get output of SP_HELP_JOB into a script?

    Not sure it will work, but why not try?

    SET @sql = insert into #TempJobTable

      EXEC('execute sp_help_job @category_name=N''REPL-Merge'', @enabled=1, @execution_status=4')

     

  • RE: Number of Mondays between two dates

    Run

    select (@@Datefirst + Datepart(dw, YourDateField) - 2) %7 +1

    FROM ..

    with different Datefirst settings and see what you can get from it.

  • RE: help needed with a set based update

    Add

    GROUP BY T2.DayNumber

    at the end of my script.

    For 6 hours you can use

    datediff(hh, 0, datetimestamp) / 6

    Because all values are int it will return number of 6 hours...

  • RE: network name with T-SQL

    From BOL: (what's an idea to read it time to time! )

    HOST_NAME

    Returns the workstation name.

    Syntax

    HOST_NAME ( )

    Return Types

    nchar

  • RE: simple query

    HAVING to be used only with aggregated values.

    WHERE is right in this case.

    Distinct is redundant if you are using GROUP BY.

    SELECT u2.EMPLOYID, u1.TRXBEGDT, u1.TRXENDDT

    FROM UPR30300 u1 INNER JOIN

    UPR30100 u2 ON...

  • RE: help needed with a set based update

    Actually you don't need any flag.

    Select count(T1.barcode) as NumberOfMembers, dateadd(dd, T2.DayNumber, 0) as DateRecorded

    FROM MyTable T1

    INNER JOIN (

            select barcode, datediff(dd, 0, datetimestamp) DayNumber -- if your time span is...

  • RE: Inserting dynamic sql resultset into table variable

    Why not

    INSERT INTO #usertable EXEC ('SELECT * FROM users WHERE ... ')

  • RE: Displaying Data from a table

    Select SUM(case when type = 'White' then Num_Avail else NULL end) as Available_White, SUM(case when type = 'Blue' then Num_Avail else NULL end) as Available_Blue, SUM(Num_Avail) as Total...

  • RE: TSQL - Minimum of numeric value

    If you return int you not gonna have 00455, it will be just 455.

    If you really need 00455 it must be varchar.

Viewing 15 posts - 5,596 through 5,610 (of 6,036 total)