Forum Replies Created

Viewing 15 posts - 4,081 through 4,095 (of 7,614 total)

  • RE: DBCC Checkdb cannot exclusively lock database

    Fortunately SQL stores the last good DBCC date in the header data for the db.

    Run this command:

    DBCC DBINFO('<your_db_name>') WITH TABLERESULTS

    And look for a "Field" value of "dbi_dbccLastKnownGood" (or similar): the...

  • RE: Mystery Value in Variable

    The value for @DataSourceJobRevenue must be passed in as a parameter value when the proc is run. For example:

    EXEC dbo.ImportJobRevenue 'JobRevenueValue'

    It's a required parameter, so its value must be...

  • RE: does following query needs union or using cases/isnull/coalace will do.

    It might be worth trying code below, as it seems to limit the number of "j" lookups required. A nested-loop join didn't prevent the extra lookups -- for whatever...

  • RE: Bones of SQL - Practical Calendar Queries

    whenriksen (10/17/2016)


    ScottPletcher (10/17/2016)


    Rather unfair to cut off the part where I asked what specifically are your requirements, because you've never stated them clearly, and then to blast me for not...

  • RE: Bones of SQL - Practical Calendar Queries

    whenriksen (10/17/2016)


    ScottPletcher (10/14/2016)


    If you just want a list of Sunday dates that are two weeks apart from a given starting date:

    SELECT COUNT(*),

    ...

  • RE: Bones of SQL - Practical Calendar Queries

    whenriksen (10/14/2016)


    First day of the business week is Monday.

    What do you recommend?

    I posted code that did that type of calc already. What specifically are you trying to list?

    If you...

  • RE: Bones of SQL - Practical Calendar Queries

    whenriksen (10/14/2016)


    You made me curious and its been a quiet day.

    SELECT COUNT(*),

    CAST(DATEADD(WEEK, DATEDIFF(WEEK, '20061231', DATEADD(DAY, 7

    - CASE DATEPART(WEEKDAY, o.modify_date) WHEN...

  • RE: Split String On Delimiter

    Here's a simple, brute-force -- but still no looping -- method, if you prefer that.

    SELECT

    string AS original_string,

    CASE WHEN are_enough_delims_present = 0 THEN...

  • RE: Multiple date periods aggregated in one table or query

    Typically a single query works best in that case, since the ytd query will by definition include the other data. Not sure what your definition of "week" is, but...

  • RE: Bones of SQL - Practical Calendar Queries

    whenriksen (10/14/2016)


    ScottPletcher (10/14/2016)


    Wow, that's a fascinating statement. Computers are known for doing billions of certain mathematical calcs per second (graphics chips hit trillions). Under no circumstances I know...

  • RE: Stock Updation Trigger on multiple rows deletion

    spaghettidba (10/14/2016)

    Generally speaking, triggers are a very bad place to implement business logic, because they make the code difficult to debug/follow. They are some sort of "hidden" code that is...

  • RE: Bones of SQL - Practical Calendar Queries

    The Dixie Flatline (10/13/2016)

    Also, although I haven't done time trials, I have no trouble believing that sometimes a simple index seek can take less time than a complex calculation against...

  • RE: Bones of SQL - Practical Calendar Queries

    whenriksen (10/13/2016)


    ScottPletcher (10/13/2016)


    I don't see how that would be the case. Couldn't you just use simple math to calc the pay periods, then join to the pre-calc'd dates? ...

  • RE: update trigger get fields before and after update

    You'll want to match directly on id, then you can use CHECKSUM across the other columns. Remember to always think set-based when possible, to get max benefits from SQL's processing.

    SET...

  • RE: Bones of SQL - Practical Calendar Queries

    whenriksen (10/13/2016)


    Another benefit to using the calendar table rather than the Select DateAdd, performance is much better when used for filtering/grouping.

    One request I received at my work was to see...

Viewing 15 posts - 4,081 through 4,095 (of 7,614 total)