Forum Replies Created

Viewing 15 posts - 49,381 through 49,395 (of 49,552 total)

  • RE: Selecting only 2 latest records

    Select [fields] FROM Movies INNER JOIN Comments ON [join clause]

    WHERE CommentID IN

     (SELECT TOP 2 CommentID From Comments c Where Comments.MovieID=Movies.MovieID ORDER BY TimeStamp DESC)

    Should work. You'll have to change...

    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: Efficient trigger type

    No difference between FOR and AFTER

    From Books online

  • AFTER triggers are executed after the action of the INSERT, UPDATE, or DELETE statement is performed. Specifying AFTER is the same as specifying FOR,...
  • 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: xstatus in sysxlogins

    And bear in mind that if someone has managed to update a system table in the master database, then they're already compromised that server to a large degree.

    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 could I return the next row(Or 8th row for example)

    SELECT TOP 1 ... FROM .... WHERE pk NOT IN (SELECT TOP n pk FROM table ORDER BY <3_varchar_columns_here> ) 

    ORDER BY <3_varchar_columns_here>

    That should give you a good start.

    HTH

    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: String manipulate

    SQL's not overly fond of double quotes. In fact, if quoted identifiers is set on (which is a default) your query returns the following error

    Server: Msg 207, Level 16, State...

    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: String manipulate

    The quotes are in the wrong place. Try this

    set @str = ' where strs in (''40301'',''40301.16'') '

    The rest of atra's query should be fine.

    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: String manipulate

    Look up charindex and substring in Books online.

    Basically, use Charindex to find the location of the quotes in the string, then substring to extract the portion you want.

    DECLARE @str VARCHAR(15)

    SET...

    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 could I return the next row(Or 8th row for example)

    Ach, do a search through this forum. There have been several posts recently about how to get the nth row of a table. You should be able to find one...

    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: Problem with Trigger/View

    If you're asking how you get the just inserted rows, have a look in Books Online for details of the inserted and deleted tables.

    the inserted table will contain the ust...

    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: Transaction DeadLock

    Not necessarily. If the update affects a large portion of the table there's a good chance that SQL will take page, extent or even table locks.

    Sanjeev, can you post 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: Question of the Day for 23 Sep 2005

    Agreed.

    I don't have a DB design book handy, but iirc it only applies in certain very specific circumstances and usually something in 3rd normal is also in BCNF

    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: Trigger Help

    Seriously, if any of my collegues submitted a trigger with...

    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: Trigger Help

    'inserted' is only a stub of the new record

    Not sure what you mean by that. inserted contains all the fields that are in the table the trigger is on. If...

    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: getting violation of PK (duplicate records) error

    Look in Books online. Exists keyword under Transact-SQL reference.

    Essentially I'm saying check Table2 for any records that have an ID, CreateDate combo that is in table 1 and exclude them.

    It's much...

    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: getting violation of PK (duplicate records) error

    Looks fine.

    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 - 49,381 through 49,395 (of 49,552 total)