Forum Replies Created

Viewing 15 posts - 4,801 through 4,815 (of 7,614 total)

  • RE: Date issue

    You just need to adjust the numbers in the calc below until it returns the date you want. I put my best guess in, but adjust as needed.

    --To stand-alone...

  • RE: One of the most complex Views i have ever seen (View nested into another view)

    SQLPain (9/14/2015)


    Thanks Scott,

    How do I fix this code:

    AppDetails.DateDetailDisposed BETWEEN getdate() - 25 AND getdate() - 20

    I only need getdate() -21, but that's giving me blank output

    WHERE ... AND

    ...

  • RE: One of the most complex Views i have ever seen (View nested into another view)

    Check the compatibility level of the db. Compatibility needs to be at least 90 for ROW_NUMBER() to work.

  • RE: Trouble w/ a WHERE statement.

    Hmm, interesting. I thought the InspectionId was a "primary key", and therefore unique. Sorry, I'm confused now about the data structure and relationships.

  • RE: Trouble w/ a WHERE statement.

    From what you've described, I think this will select the rows you need. Btw, I hope the table isn't clustered on that guid, even though that is the PK.

    Edit:...

  • RE: TRUNCATE with WAITFOR DELAY

    No, I don't recall anything like that, not on newer versions. Maybe under SQL 6.5, which I never used. Perhaps under SQL 7.0, which probably didn't defer the...

  • RE: Delete large number of records

    Jeff Moden (9/9/2015)

    It looks like someone may have followed the old idea of adding one index to each column that could ever be used in a WHERE clause and that's...

  • RE: Cross Apply with parameterized function

    Check the compatibility level of the dbs. If that is too low, you'll get that syntax error, since earlier versions of SQL didn't allow that type of reference.

    Edit: OOPS,...

  • RE: Delete large number of records

    Why do you refuse to create a clustered index??

    Since you have Enterprise Edition, you can create the index online so it will barely, if at all, affect other users.

    Drop all...

  • RE: Query written by a beginner

    Quite right, sorry, left that table out of the outer query. Also forgot to check the CollectorCode in the inner query, I've added that back as well:

    SELECT

    H_Totals.David

    , H_Totals.DavidCt

    ,...

  • RE: Query written by a beginner

    I don't see anywhere that the dbo.Company table is being used, so I removed it.

    I also removed the multiple JOINs, although I did not add a GROUP BY...

  • RE: Delete large number of records

    You could partition the table, but it's likely overkill in this situation. All you probably need is the best clustered index and only the nonclustered index(es) you actually need,...

  • RE: Delete large number of records

    There are two main reasons it's taking so long:

    1) no clustered index

    2) too many nonclustered indexes

    My best guess is that Trx_Date should be the clustered index. But we need...

  • RE: matainence jobs are failing

    I don't use MPs either.

    But check for missing dbs. For example, maybe a db was moved or renamed.

  • RE: ISNULL vs IS NULL performance

    There's a simple rule for this:

    NEVER use ISNULL() in a WHERE or JOIN clause.

    You can easily code around it, and it could cause performance issues. Even if there's no...

Viewing 15 posts - 4,801 through 4,815 (of 7,614 total)