How to find a record to delete?

  • Hi,

    I am not a DBA, (well not yet) but I am trying to find a record to delete it in the SQL end of our MS CRM Database, and am having no luck at all...

    I can find the table that the entry is in,but not the entry itself...

    There is a table in CRM called TeamBase, which is supposed to hold any teams that have been created. When there is a mistake and someone creates a team that they shouldn't, you cannot delete it from within CRM, so you have to go through the SQL Database to delete the record from there...

    can someone help point me in the right direction please 🙂

    thanks and regards

    Rossco

  • Not much to go on here. If the table has a primary key, select the row from the table where the primary key equals the value for the team you want to delete.

    For more help, please post the table schema including primary key and sample data.

    Greg

  • Hi Greg,

    thanks for the reply, I will get that info and post back soon 🙂

    cheers

    Rossco

  • Greg Charles (11/5/2008)


    Not much to go on here. If the table has a primary key, select the row from the table where the primary key equals the value for the team you want to delete.

    For more help, please post the table schema including primary key and sample data.

    Hi Greg,

    not sure if this is the right info for you or not, but here are the images...

    plus the PK = TeamID

    Hope this helps

    cheers & regards

    Rossco

  • So, do you know the TeamId value for the row you want to delete? If not, can you find it by querying for Name or some other identifying column?

    How have you tried to find the row you want to delete?

    Greg

  • Hi Greg,

    Yes I know the name of the TeamID, it is "ICT Services" but it is the finding it that I am having a problem with, then I need to delete it and any traces of it, off the system.....

    Chees

    Rossco

  • "ICT Services" must be the name rather than the TeamId since TeamId is a 16 byte GUID. Assuming that, try this to select the row:

    select TeamID from dbo.TeamBase

    where Name like 'ICT Services%'

    ...and this to delete it:

    delete from dbo.TeamBase

    where TeamId = value returned by the previous query

    If the SELECT doesn't return any rows, I'd say it doesn't exist in the table.

    Greg

  • But back up your table first !!!

    Select * into TeamBase_20081106

    from TeamBase

    Then use the select statement to get a count of how many you will delete. When you delete, the count should be the same.

    Also, when I do these on-the-fly fixes, I do them inside a transaction so I can roll back if I made a mistake.

    For instance

    [font="Courier New"]begin tran

    delete from dbo.TeamBase

    where TeamId = value returned by the previous query

    -- " ooooops .... I deleted the wrong records !!"

    ROLLBACK

    run COMMIT when you know it's correct[/font]

  • Thanks Greg & Homebrew...:-)

    very much appreciated

    kind regards

    Rossco

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply