Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. using sp_MSForEachTable to delete data with a where clause [modified]

using sp_MSForEachTable to delete data with a where clause [modified]

Scheduled Pinned Locked Moved Database
databasesharepointhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PrashantJ
    wrote on last edited by
    #1

    Hi All, I wanted to use the undocumented SP sp_MSForEachTable to selectively delete data from tables. So in short i want to achieve something like this using sp_MSForEachTable. delete from TableName where Date = '2007-01-03' I looked at various queries on the internet using sp_MSForEachTable, but was not able to find out the usage of sp_MSForEachTable with a "Where" clause, so if anybody has the query or links request to post it here. All that I found was to delete all data from all the tables in the db. I tried using the @whereand option like this, but the got an error saying Invalid column: SomeDate. I have this column in all the tables in that database. I did a quick check looping thro all the tables using cursors and that works fine. EXEC sp_MSForEachTable @command1='DELETE FROM ?' ,@whereand='and SomeDate = "2007-01-15"' Thanks. PJ -- modified at 14:39 Monday 15th January, 2007

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups