Results 1 to 7 of 7

Thread: Sql Helpp!!!!!

  1. #1
    Join Date
    Dec 2003
    Posts
    4

    Unanswered: Sql Helpp!!!!!

    Hi guys,

    I am not a programmer OR a database guru, however, if I can do this following task, I will be a hero in my small company. Help me out? Please excuse my non programming language too, but I'm sure you guys will figure out what I need to do.

    I have a number of tables in which there are a number of rows, each with a number of columns that are the field names.

    For example, in a table called "Items", I have different columns that have the various item related fields. So the table looks like:

    Item Code,Item_Description,Item_Size etc

    Now the table has about 5000 rows and I need to delete certain rows depending on the Item Code.

    I also have to delete ALL identical items from ALL the tables in the database, but in a particular order.

    For example, if I try to delete item number 123456 from table "Items", SQL wont allow me to do that until I have deleted the corresponding row from the table "Quotations"

    I therefore need to delete these items from all the tables in a particular sequence.

    There are 16 Tables that I need to delete these items from and about 100 + items that need to be deleted.

    I know how to Query each table for those particular item codes and then delete them manually (by selecting the row and right clicking delete), but as you can appreciate, this will take a LOOOooong time and I may need to repeat this process several times in the future.

    Is there any way that I can enter all the item codes in one place somewhere (maybe Excel??!) and have some kind of automatic process that looks at my itemcodes and goes and deletes those rows in all the tables that I specify (in order ...like Delete those rows in Table "Quotations" first, then in table "Delivery_Status", then in table "ITems"... etc).

    Am I dreaming? There mst be an easy solution that you SQL gurus must know...

    Help me PUH lease??!?

  2. #2
    Join Date
    Dec 2003
    Posts
    4

    By the Way

    By the way, I am running SQL Server 2000 (I think)... and have Enterprise Manager Version 8.0.

  3. #3
    Join Date
    Nov 2003
    Posts
    11
    u can make a small program in java or something to delete that way u don't have to write the query againand again

    or
    if u wanna dlete from multiple tables and multiple rows
    u can do soemthign like this


    Delete from table1, table2, table3
    where Condition = 'blahblahblah'


    hope this helps
    later

  4. #4
    Join Date
    Dec 2003
    Posts
    4
    Dude,

    Thanks for the help, but like I said, I'm not a programmer, so basically the script that you have suggested seems to be the right option. Where do I enter it in Enterprise Manager though? And is there any way that I can make it a loop so that it asks me every time the item code that I need to delete and then goes and deletes it from the sequence of tables?

    Thanks a lot.

    Najib

  5. #5
    Join Date
    Nov 2003
    Posts
    11
    Since u are posting the question in sql and pl/sql forums, it means that u have knowledge of sql , and as u asked that what should u do so u don have to right the statements again and again, i would suggest that instead of writing and running it in the application(enterprise manager), u should write the query in an editor and then run it on sql, this way all u have to is change the table names and the condtion in the text editor without writing the whole query again and agaian. i never worked with enterprise manager but if it is releated to sql or pl/sql then that above query will work.

    in text editor
    write the query
    save it as extension ".sql"
    and then run it whatever application u have

    and about this question

    And is there any way that I can make it a loop so that it asks me every time the item code that I need to delete and then goes and deletes it from the sequence of tables?

    "that way u gotta built a PROGRAM."

  6. #6
    Join Date
    Nov 2003
    Posts
    11
    i just looked at enterprise manager, dude i have no idea where to run that query from? but i guess u are asking the question in wrong forum, i think u are suppose to be in Microsoft sql server forum may be theycan help u

  7. #7
    Join Date
    Dec 2003
    Posts
    4

    Talking Thanks man

    Originally posted by simarjitraina
    i just looked at enterprise manager, dude i have no idea where to run that query from? but i guess u are asking the question in wrong forum, i think u are suppose to be in Microsoft sql server forum may be theycan help u
    Muchas Gracias Amigo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •