Forum Replies Created

Viewing 15 posts - 48,826 through 48,840 (of 49,552 total)

  • RE: last record

    Which will work if you have an identity column called recordID

    Inherently, SQL keeps no record of the 'last' row. If there's an identity column or a last inserted time...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: @@rowcount Returns 0

    Something I discovered yesterday is that IF resets @@rowcount.

    The following code enters the if, but returns 0 as the rowcount.

    select

    * from

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Drop and recreate Index

    You also don't need to drop and recreate an index when you alter a column.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: About bookmark lookup

    A bookmark lookup occurs when SQL uses a nonclustered index to locate the rows required for a query, but the index does not contain all the columns needed by the...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Last time statistics were updated?

    This the one you're looking for? Used in a select statement, so you can check the dates of all stats in the system with a single query.

    STATS_DATE

    ...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Weird pattern of behaviour

    The SELECT returns at most a single row for every entry in the IN clause.

    Yes, but how many enteries do you typically have in the IN clause? There comes a...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: IF DATABASE EXISTS ???

    That's still going to give an error, from the parsing of the USE statement 

    Could not locate entry in sysdatabases for database 'MyDB'. No entry found with that name....

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Does JOIN order effect efficiency?

    The join order does not affect performance. The query optimiser will reorder the join to find the cheapest plan possible. I think it's been this way since SQL 7

    I tried...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Weird pattern of behaviour

    SELECT t0.col1,

    t0.col2,

    t0.col3,

    t0.col4,

    t0.col5,

    t0.col6,

    t0.col7,

    t0.col8

    FROM dbo.table1 t0

    WHERE (t0.col8 IN (?))

    That select will table scan if the number of records returned exceeds more than about 1% of the table. I can't tell whether the in...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Truncate Log didn''''t work for all databases

    Please don't ever run ShrinkDatabase on a production database without a very, very good reason. All you're going to achieve is to fragment all your indexes badly and force the...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Weird pattern of behaviour

    Perhaps query hints are in order. I'll see what I can do.

    Recomended practice is to never add query hints unless you know exactly what you're doing and why you're adding...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Data Contention - How do I solve it ?

    Sounds like your watchdog process is the problem then.

    I notice that your orders table doesn't have a clustered index. Adding one may help out, especially with the reads, if it's...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Update Trigger Help

    Why do you want to store the code and the code ID in the billing detail table? It's poor table design. (Unless this is some form of data warehouse and...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: Data Contention - How do I solve it ?

    You'll have to keep a watch on sp_lock, see if you get table locks. However in general, if you have a lot of inserts and updates to a table, then...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • RE: how to check system errorlog for a previous date, It''''s very urgent...

    but u know there is an @@error global function in sql

    @@Error just returns the error statement of the previous command in a TSQL batch. If the previous command executed without...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 48,826 through 48,840 (of 49,552 total)