Delete tables (cleanly)

hi guys,
How do we (1) delete tables (2) delete table entries
and together deleting the other entries with corresponding foreign key?
Thanks
Message was edited by:
        TY Ng

Hi ,
U can delete entries from the table using the following syntax.
DELETE FROM <TABLENAME>.
Variants:
1. DELETE FROM dbtab WHERE cond.
DELETE FROM (dbtabname) WHERE cond.
2. DELETE dbtab.
DELETE *dbtab.
DELETE (dbtabname) ...
3. DELETE dbtab FROM TABLE itab.
DELETE (dbtabname) FROM TABLE itab.
4. DELETE dbtab VERSION vers.
DELETE *dbtab VERSION vers.
Effect
Deletes lines from a database table (see Relational Databases ). You can specify the name of the database table either in the program itself with DELETE FROM dbtab ... or at runtime as the contents of the field dbtabname with DELETE FROM (dbtabname) .... In both cases, the database table must be known to the ABAP Dictionary. Only data from the current client is usually deleted. You can delete data using a view only if the view refers to a single table and was created in the ABAP Dictionary with the maintenance status "No restriction".
DELETE belongs to the Open SQL command set.
Notes
The DELETE statement does not perform authorization checks. You must program these yourself.
The final (irrevocable) deletion of lines with the DELETE statement is not performed until after a database commit (see Logical Unit of Work (LUW)). Prior to this, you can reverse any database update with a database rollback (see Programming Transactions).
You cannot rely exclusively on the locking mechanism of the database system to synchronize several users trying to access the same dataset at the same time. You should therefore use the SAP locking mechanism.
Variant 1
DELETE FROM dbtab WHERE cond.
DELETE FROM (dbtabname) WHERE cond.
Addition:
... CLIENT SPECIFIED
Effect
Deletes lines in a database table that satisfy the WHERE clause cond. With this variant, specification of a WHERE condition is obligatory .
When the statement has been executed, the system field SY-DBCNT contains the number of deleted lines.
The return code is set as follows:
SY-SUBRC = 0:
At least one line was deleted.
SY-SUBRC = 4:
No lines were deleted, since no line was selected.
Example
Delete all bookings for the Lufthansa flight 0400 on 02.28.1995 (in the current client):
TABLES SBOOK.
DELETE FROM SBOOK WHERE CARRID = 'LH'       AND
                        CONNID = '0400'     AND
                        FLDATE = '19950228'.
Note
To delete all the lines in a table, you must specify a WHERE condition that is true for all lines. You can achieve this with
... WHERE f IN itab
If the internal table itab is empty, such a condition would select all lines.
Addition
... CLIENT SPECIFIED
Effect
Switches off automatic client handling. This allows you to delete data across all clients in the case of client-specific tables. The client field is then treated like a normal table field, for which you can formulate suitable conditions in the WHERE clause.
You must specify the addition CLIENT SPECIFIED immediately after the name of the database table.
Variant 2
DELETE dbtab.
DELETE *dbtab.
DELETE (dbtabname) ...
Additions:
1. ... FROM wa
2. ... CLIENT SPECIFIED
See Short forms not allowed and * work areas not allowed.
Effect
These are SAP-specific short forms used to delete one line of a database table. If the name of the database table is specified in the program, the primary key of the line to be deleted is taken from the specified work area - dbtab or *dbtab. If the name of the database table is not determined until runtime ( DELETE (dbtabname) ...), the addition ... FROM wa is obligatory .
When the statement has been executed, the system field SY-DBCNT contains the number of deleted lines (0 or 1).
The return code is set as follows:
SY-SUBRC = 0:
The line was deleted.
SY-SUBRC = 4:
No lines could be deleted, since no line exists with the primary key specified.
Example
Delete the booking with the booking number 3 for the Lufthansa flight 0400 on 28.02.1995 (in the current client):
TABLES SBOOK.
SBOOK-CARRID = 'LH'.
SBOOK-CONNID = '0400'.
SBOOK-FLDATE = '19950228'.
SBOOK-BOOKID = '00000003'.
DELETE  SBOOK.
Addition 1
... FROM wa
Effect
Takes the primary key for the line to be deleted not from the table work area dbtab, but from the explicitly specified work area wa. Here, the key values from left to right are taken from wa according to the structure of the primary key in the table work area dbtab (see TABLES). The structure of wa is not taken into account. Therefore, the work area wa must be at least as wide (see DATA) as the primary key in the table work area dbtab and the alignment of the work area wa must correspond to the alignment of the primary key in the table work area. Otherwise, you get a runtime error.
Note
If a work area is not explicitly specified, the values for the line to be deleted are taken from the table work area dbtab, even if the statement appears in a subroutine (see FORM) or function module (see FUNCTION) where the table work area is stored in a formal parameter or a local variable of the same name.
Addition 2
... CLIENT SPECIFIED
Effect
As with variant 1.
Variant 3
DELETE dbtab FROM TABLE itab.
DELETE (dbtabname) FROM TABLE itab.
Addition:
... CLIENT SPECIFIED
Effect
Mass deletion: Deletes all database table lines for which the internal table itab contains values for the primary key fields. The lines of the internal table itab must satisfy the same condition as the work area wa in addition 1 to variant 2.
The system field SY-DBCNT contains the number of deleted lines, i.e. the number of lines of the internal table itab for whose key values there were lines in the database table dbtab.
The return code is set as follows:
SY-SUBRC = 0:
All lines from itab could be used to delete lines from dbtab.
SY-SUBRC = 4:
For at least one line of the internal table in the database table, there was no line with the same primary key. All found lines are deleted.
Note
If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0.
Addition
... CLIENT SPECIFIED
Effect
As with variant 1.
Variant 4
DELETE dbtab VERSION vers.
DELETE *dbtab VERSION vers.
This variant is not allowed in an ABAP Objects context. See VERSION addition not allowed.
Note
This variant is now obsolete, since variants 1 - 3 allow you to specify the database table name dynamically.
Effect
Deletes a line in a database table, the name of which is taken from the field vers at runtime. The database table must be known to the ABAP Dictionary and its name must conform to the following naming convention: It must begin with 'T' and can consist of four additional characters. The field vers must contain the table name without a leading 'T'. Only lines in the current client are deleted. The line to be deleted is taken from the statically specified table work area dbtab or *dbtab.
The return code is set as follows:
SY-SUBRC = 0:
The line was deleted.
SY-SUBRC = 4:
No lines could be deleted because no line existed with the specified primary key.
<b>Reward points if this helps,</b>
Kiran

Similar Messages

  • Update or delete table from XML

    Is it possible to update or delete table's row from XML file?
    Thanks
    Prasanta De

    Hi Steve,
    Thanks for your reply but I could not find any example from the documentation for update-request or delete-request. I need your help in this regards.
    1. I have emp table with many rows and the simple structure like this
    DEPTNO NUMBER(2)
    EMPNO NUMBER(2)
    EMPNAME VARCHAR2(20)
    EMPSAL NUMBER(8,2)
    Key is defined on deptno and empno
    2. I have a xml file like this
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW num="1">
    <DEPTNO>1</DEPTNO>
    <EMPNO>11</EMPNO>
    <EMPSAL>1111.11</EMPSAL>
    </ROW>
    <ROW num="2">
    <DEPTNO>1</DEPTNO>
    <EMPNO>12</EMPNO>
    <EMPSAL>2222.22</EMPSAL>
    </ROW>
    <ROW num="3">
    <DEPTNO>1</DEPTNO>
    <EMPNO>13</EMPNO>
    <EMPSAL>3333.33</EMPSAL>
    </ROW>
    </ROWSET>
    3. I want that xsql servlet will read this xml file and update EMPSAL column depending upon the value of DEPTNO and EMPNO from xml file.
    Please let me know how I should use update-request in xsql page.
    Thanks
    Prasanta De
    null

  • DELETE TABLE STATEMENT WITHIN A LOOP IN A PROCEDURE

    i am using delete table tablename statement inside a cursor for loop which is inside a procedure
    it is telling error in that delete statement
    can't i put it inside the loop

    you can only run DDL commands like create, drop etc in pl/sql by using "execute immediate" or dbms_sql package. when you use either of the two mentioned , it will work anywhere in PL/SQL , yes even in a loop. Note that the commit on DDL are implicit , so take care of your transactions if any ..
    --Samson                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Error in code generation for deleting table BUT000_TD

    Hi,
    Did anyone encounter this error while working on EEWB ?
    I created the project extension via EEWB and completed the wizard setting with the package (dev. class) value as $temp as I wanted to test it locally.
    One of the errors, that I got is:
    Error in code generation for deleting table BUT000_TD
        Message no. DA464
    Diagnosis
        This error message indicates that internal inconsistencies exist.
    Procedure
        Please consult SAP.

    Hi,
    As I mentioned in my previous post kindly check the consistency of the structure BUT000_TD.
    Regards,
    Sudheer.

  • Empty Log files not deleted by Cleaner

    Hi,
    we have a NoSql database installed on 3 nodes with a replication factor of 3 (see exact topology below).
    We run a test which consisted in the following operations repeated in a loop : store a LOB, read it , delete it.
    store.putLOB(key, new ByteArrayInputStream(source),Durability.COMMIT_SYNC, 5, TimeUnit.SECONDS);
    store.getLOB(key,Consistency.NONE_REQUIRED, 5, TimeUnit.SECONDS);
    store.deleteLOB(key, Durability.COMMIT_SYNC, 5, TimeUnit.SECONDS);
    During the test the space occupied by the database continues to grow !!
    Cleaner threads are running but logs these warnings:
    2015-02-03 14:32:58.936 UTC WARNING [rg3-rn2] JE: Replication prevents deletion of 12 files by Cleaner. Start file=0x0 holds CBVLSN 1, end file=0xe holds last VLSN 24,393
    2015-02-03 14:32:58.937 UTC WARNING [rg3-rn2] JE: Cleaner has 12 files not deleted because they are protected by replication.
    2015-02-03 14:32:58.920 UTC WARNING [rg3-rn1] JE: Replication prevents deletion of 12 files by Cleaner. Start file=0x0 holds CBVLSN 1, end file=0xe holds last VLSN 24,393
    2015-02-03 14:32:58.921 UTC WARNING [rg3-rn1] JE: Cleaner has 12 files not deleted because they are protected by replication.
    2015-02-03 14:32:58.908 UTC WARNING [rg3-rn3] JE: Replication prevents deletion of 12 files by Cleaner. Start file=0x0 holds CBVLSN 1, end file=0xe holds last VLSN 24,393
    2015-02-03 14:32:58.909 UTC WARNING [rg3-rn3] JE: Cleaner has 12 files not deleted because they are protected by replication.
    2015-02-03 14:33:31.704 UTC INFO [rg3-rn2] JE: Chose lowest utilized file for cleaning. fileChosen: 0xc (adjustment disabled) totalUtilization: 1 bestFileUtilization: 0 isProbe: false
    2015-02-03 14:33:32.137 UTC INFO [rg3-rn2] JE: CleanerRun 13 ends on file 0xc probe=false invokedFromDaemon=true finished=true fileDeleted=false nEntriesRead=1129 nINsObsolete=64 nINsCleaned=2 nINsDead=0 nINsMigrated=2 nBINDeltasObsolete=2 nBINDeltasCleaned=0 nBINDeltasDead=0 nBINDeltasMigrated=0 nLNsObsolete=971 nLNsCleaned=88 nLNsDead=0 nLNsMigrated=88 nLNsMarked=0 nLNQueueHits=73 nLNsLocked=0 logSummary=<CleanerLogSummary endFileNumAtLastAdjustment="0xe" initialAdjustments="5" recentLNSizesAndCounts=""> inSummary=<INSummary totalINCount="68" totalINSize="7570" totalBINDeltaCount="2" totalBINDeltaSize="254" obsoleteINCount="66" obsoleteINSize="7029" obsoleteBINDeltaCount="2" obsoleteBINDeltaSize="254"/> estFileSummary=<summary totalCount="2072" totalSize="13069531" totalINCount="68" totalINSize="7570" totalLNCount="1059" totalLNSize="13024352" maxLNSize="102482" obsoleteINCount="66" obsoleteLNCount="971" obsoleteLNSize="12974449" obsoleteLNSizeCounted="971" getObsoleteSize="13019405" getObsoleteINSize="7347" getObsoleteLNSize="12974449" getMaxObsoleteSize="13019405" getMaxObsoleteLNSize="12974449" getAvgObsoleteLNSizeNotCounted="NaN"/> recalcFileSummary=<summary totalCount="2072" totalSize="13069531" totalINCount="68" totalINSize="7570" totalLNCount="1059" totalLNSize="13024352" maxLNSize="0" obsoleteINCount="66" obsoleteLNCount="971" obsoleteLNSize="12974449" obsoleteLNSizeCounted="971" getObsoleteSize="13019405" getObsoleteINSize="7347" getObsoleteLNSize="12974449" getMaxObsoleteSize="13019405" getMaxObsoleteLNSize="12974449" getAvgObsoleteLNSizeNotCounted="NaN"/> lnSizeCorrection=NaN newLnSizeCorrection=NaN estimatedUtilization=0 correctedUtilization=0 recalcUtilization=0 correctionRejected=false
    Log files are not delete even if empty as seen using DBSpace utility:
    Space -h /mam2g/data/sn1/u01/rg2-rn1/env/ib/kvstore.jar com.sleepycat.je.util.Db
      File    Size (KB)  % Used
    00000000      12743       0
    00000001      12785       0
    00000002      12725       0
    00000003      12719       0
    00000004      12703       0
    00000005      12751       0
    00000006      12795       0
    00000007      12725       0
    00000008      12752       0
    00000009      12720       0
    0000000a      12723       0
    0000000b      12764       0
    0000000c      12715       0
    0000000d      12799       0
    0000000e      12724       1
    0000000f       5717       0
    TOTALS      196867       0
    Here is the configured topology:
    kv-> show topology
    store=MMS-KVstore  numPartitions=90 sequence=106
      zn: id=zn1 name=MAMHA repFactor=3 type=PRIMARY
      sn=[sn1] zn:[id=zn1 name=MAMHA] 192.168.144.11:5000 capacity=3 RUNNING
        [rg1-rn1] RUNNING
                 single-op avg latency=4.414467 ms   multi-op avg latency=0.0 ms
        [rg2-rn1] RUNNING
                 single-op avg latency=1.5962526 ms   multi-op avg latency=0.0 ms
        [rg3-rn1] RUNNING
                 single-op avg latency=1.3068943 ms   multi-op avg latency=0.0 ms
      sn=[sn2] zn:[id=zn1 name=MAMHA] 192.168.144.12:6000 capacity=3 RUNNING
        [rg1-rn2] RUNNING
                 single-op avg latency=1.5670061 ms   multi-op avg latency=0.0 ms
        [rg2-rn2] RUNNING
                 single-op avg latency=8.637241 ms   multi-op avg latency=0.0 ms
        [rg3-rn2] RUNNING
                 single-op avg latency=1.370075 ms   multi-op avg latency=0.0 ms
      sn=[sn3] zn:[id=zn1 name=MAMHA] 192.168.144.35:7000 capacity=3 RUNNING
        [rg1-rn3] RUNNING
                 single-op avg latency=1.4707285 ms   multi-op avg latency=0.0 ms
        [rg2-rn3] RUNNING
                 single-op avg latency=1.5334034 ms   multi-op avg latency=0.0 ms
        [rg3-rn3] RUNNING
                 single-op avg latency=9.05199 ms   multi-op avg latency=0.0 ms
      shard=[rg1] num partitions=30
        [rg1-rn1] sn=sn1
        [rg1-rn2] sn=sn2
        [rg1-rn3] sn=sn3
      shard=[rg2] num partitions=30
        [rg2-rn1] sn=sn1
        [rg2-rn2] sn=sn2
        [rg2-rn3] sn=sn3
      shard=[rg3] num partitions=30
        [rg3-rn1] sn=sn1
        [rg3-rn2] sn=sn2
        [rg3-rn3] sn=sn3
    Why empty files are not delete by cleaner? Why empty log files are protected by replicas if all the replicas seam to be aligned with the master ?
    java -jar /mam2g/kv-3.2.5/lib/kvstore.jar ping -host 192.168.144.11 -port 5000
    Pinging components of store MMS-KVstore based upon topology sequence #106
    Time: 2015-02-03 13:44:57 UTC
    MMS-KVstore comprises 90 partitions and 3 Storage Nodes
    Storage Node [sn1] on 192.168.144.11:5000    Zone: [name=MAMHA id=zn1 type=PRIMARY]    Status: RUNNING   Ver: 12cR1.3.2.5 2014-12-05 01:47:33 UTC  Build id: 7ab4544136f5
            Rep Node [rg1-rn1]      Status: RUNNING,MASTER at sequence number: 24,413 haPort: 5011
            Rep Node [rg2-rn1]      Status: RUNNING,REPLICA at sequence number: 13,277 haPort: 5012
            Rep Node [rg3-rn1]      Status: RUNNING,REPLICA at sequence number: 12,829 haPort: 5013
    Storage Node [sn2] on 192.168.144.12:6000    Zone: [name=MAMHA id=zn1 type=PRIMARY]    Status: RUNNING   Ver: 12cR1.3.2.5 2014-12-05 01:47:33 UTC  Build id: 7ab4544136f5
            Rep Node [rg3-rn2]      Status: RUNNING,REPLICA at sequence number: 12,829 haPort: 6013
            Rep Node [rg2-rn2]      Status: RUNNING,MASTER at sequence number: 13,277 haPort: 6012
            Rep Node [rg1-rn2]      Status: RUNNING,REPLICA at sequence number: 24,413 haPort: 6011
    Storage Node [sn3] on 192.168.144.35:7000    Zone: [name=MAMHA id=zn1 type=PRIMARY]    Status: RUNNING   Ver: 12cR1.3.2.5 2014-12-05 01:47:33 UTC  Build id: 7ab4544136f5
            Rep Node [rg1-rn3]      Status: RUNNING,REPLICA at sequence number: 24,413 haPort: 7011
            Rep Node [rg2-rn3]      Status: RUNNING,REPLICA at sequence number: 13,277 haPort: 7012
            Rep Node [rg3-rn3]      Status: RUNNING,MASTER at sequence number: 12,829 haPort: 7013

    Solved setting a non documented parameter " je.rep.minRetainedVLSNs"
    The solution is described in NoSql forum:   Store cleaning policy

  • After reverse engineering i have still the old deleted tables

    hi ,
    i dropped a table from database schema and go to ODI and run reverse engineering on my model which linked to the database schema through my logical schema, but the deleted table still exist in my model ??? i wish this dropped table automaticly deleted from my model..

    Hi,
    Deletion actual table will not reflect while reverse engineer.
    The Meta data has been taken into ODI. It has become an object of ODI.
    So you have to directly delete the data store to remove it from ODI.
    Hope it helps.
    Regards,
    Gatha

  • How To Restore Deleted Table With It's Data To Specified Time Using 10g

    Hello Everybody
    I would like to gain from your experience in the Felid of DBA so now i am not trying to restore the full database, but i have a stupid user dropped accedintaly a single table from the database. i want to restore this table after being deleted but also i have big problem i dont have any backup for this table so if you please send to me any solution to restore this deleted table
    Notes : I have (Flash backup On , Archive Log Is On)
    it is not that the database is corrupted or anything
    Ramez S. Swires

    Hey N. Gasparotto
    Thank you for replying me. in the first thread you told me
    ( Without any flashback availability, you haven't any other choice than PITR (Point In Time Recovery)).
    i already checked i found that flashback is working and archive log are working and both are working normally and working before dropping the table and also i cant restore the table which is dropped.
    So what can i do?
    Do you have any other idea?
    Ramez S. Sawires

  • How to delete table content for particular filed in a table?

    Hi Experts,
    How to delete table content for particular field in table?
    Thanks
    Ravilla

    Is it a standard or customer table, changing a standard table with non-standard tool can raise database inconsistencies...
    Then use search tool for &SAP_EDIT (*) or look for BAPI/BDC...
    Regards,
    Raymond
    (*) Also look for notes from 1420281 - CO-OM tools: SE16N: Deactivating &SAP_EDIT to 1915828 - CO-OM-Tools: Technical enhancement of SE16N

  • GEt deleted table -Oracle 9i

    How to get deleted table back in 9i?
    Does 9i has Recycle Bin like 10g?

    A drop table is not a recoverable transaction. A delete is.
    You can rollback a delete. Or you can commit a delete. Let's say you commit a delete and afterwards realise that it was a mistake. The undo records for that delete transaction can be mined from the archive logs using LogMiner. You can thus reconstruct the undo from the logs and insert the deleted rows back into the database.
    A drop table has an implicit commit. And it not recoverable, meaning that it cannot be rolled back. There is no undo records created for a drop table. Thus you cannot mine the archive logs to find the dropped rows.
    Enter the recyclebin feature to provide a means to "un-drop" a table. Instead of actually deleting the table, it is simply renamed. The table now looks like it is gone. The data looks like it is lost. However, the table and its data still exist.
    This therefore allows the dropped table to be "un-dropped" - almost like rolling back the the DROP TABLE statement.

  • How to delete table partitions

    Hi all,
    I want to know how can I delete table partitions.I have partitioned table in schema A owned by user A.But I created table partitions in Schema B owned by user B..Now I want the partions from schema B,it says table doesn't exist and when I tried to delete the partitions from schema A ,it says partition doesn't exist,What to do ?
    Regards,
    AA.

    can you give the statements you tried (and as which user)?
    I couldn't follow your actions, sorry.
    Martin

  • Delete tables

    hi all,
    i need delete 1 table but this table have several constraints with other tables. so let said i need delete table1 but how i write my sql command to check for table2, table 3..... etc for constraints before i delete table 1 ?
    tks.

    ooo ic here is my code .
    select * from table1 a where condition in ('...............')
    and not exists (select 1 from table2 b
              where condition in ('................')
              and a.field1=b.field1)

  • Deleted Tables in Java Dictionary

    Hi all,
    I have deleted a table within the Java Dictionary. The documentation tells that it is not possible to reuse the name of a deleted table.
    But unfortunately i have to reuse this name. So my question is:
    Is there any possiblity to undelete the table or to reuse the name?
    Thanks in advance....

    Hi Florian,
    the creation of Java dictionary projects is checked against the name server. That is the reason why you cannot re-use the name just after the deletion of the table, as it could be possible that this table is already transported and re-used in another project.
    If you really know that this table name is not used somewhere else, you can remove the name reservation. This has to be done in the SLD that acts as the Name Reservation Server (in most cases it's the SLD that you also use for creating your SCs).
    There, go to the section "Name Reservation" and have a look at the reserved names of type "DB table". Delete the desired entry.
    Then you only have to restart the NWDS, as this is chaching the info from the name server. 
    On the DB, there is no issue re-using the table. But you have to keep in mind that this will result in a drop of the existing table with all the data before it is recreated.
    Best regards,
    Timo

  • Archive/delete table SXMSPMAST with MSGSTATE = 1 or 23

    Hi experts,
    In table SXMSPMAST how to change the Message Status(MSGSTATE) 1 & 23 to 3?
    Because Archive/delete job is not cleaning messages from table SXMSPMAST with Message Status(MSGSTATE) = 1 & 23.
    I already tried using RSWF_XI_UNUSED_MSGS.
    Regards

    Hi,
    Here are a few tips on how to delete messages, and also enable messages for deletion which are not in final state.
    To release messages in unarchivable statuses: http://host:port/MessagingSystem/archiving/reorgdb.jsp
    Schedule following reports weekly (depending on your error handling and reporting procedures for your system this might not be possible in your production system):
    RSXMB_CANCEL_MESSAGES
    RSXMB_CANCEL_NO_COMMIT_MSG
    RSXMB_CANCEL_NOT_REST_MESSAGES
    RSXMB_CHECK_ITFACTION
    RSWF_XI_INSTANCES_DELETE
    SXMS_REFRESH_ADAPTER_STATUS
    In addition you have the following reports dealing with enabling messages for archiving deletion
    u2022     RSWI_REGENERATE_WI2OBJ (uncheck u201CDisplay modeu201D and set for relevant dates)
    u2022     SXMS_REFRESH_ADAPTER_STATUS -     Success: all msg with adapter status 001 changed to 006 (archivable)
    u2022     RSWF_XI_UNUSED_MSGS (recommended not to run in production to avoid loosing data)
    RSXMB_SHOW_REORG_STATUS shows number of messages scheduled for archiving/deletion
    RSXMB_SHOW_STATUS shows number of messages per message status, and adapter status for messages with message status = 003 (Processed successfully)
    RSXMB_CHECK_MSG_QUEUE fixes inconsistencies by changing the message statuses 001, 009, 012 and 016 to 014/021.
    Hope this helps!
    Br,
    Kenneth

  • Deleted Table in SQL and DBML still remained relation !!!!

    Hi Dear Experts
    I've faced the serious problem please help me :( !
    I've deleted a table from SQL database and also dbml and i created new table instead
    Also in Store Procedure the new table is used
    I've checked that the old table has completely removed
    but when in want to excecute the solution (the SP it tells me that previous relation (Foreignkey )
    is still remained ?!!!!!!) 
    ***THE OLD TABLE WAS IN RELATION WITH A TABLE IN SP BUT NOW IS IN RELATION WITH NEW TABLE*****
    Why this error occured even i've have removed the table?????
    Thanks a lot

    Error Message
    the insert statment Confilicted with foreign key constarint "FK_<tableName>_<oldtable>".the conflict occurred in database,table<old table>,column'x'
    thanks a lot
    Hi nasringh,
    Could you please check the relationship and the underlying records between foreign key table and primary key table? We must insert Data into the parent table which containing the Primary Key, before attempting to insert data into the child table containing
    the Foreign Key.
    For more detail information, please take a look at the following similar thread:
    http://stackoverflow.com/questions/2965837/insert-statement-conflicted-with-the-foreign-key-constraint
    http://www.codeproject.com/Questions/281774/The-INSERT-statement-conflicted-with-the-FOREIGN-K
    Regards,
    Elvis Long
    TechNet Community Support

  • Delete table in SQL command

    Hello,
    As part of my report I populate a table then reference it in several following subreports.
    The issue I'm having is that I need to clear all the data from my table after using it to allow the report to run again (and not get multiple results)
    To do this I have tried to add a sub report at the very end (and start) of my report with the SQL command truncate table <tablename> or delete <tablename> or delete <tablename> where 1 = 1.
    When I try truncate I get an error saying that I don't have permission (despite granting it but hey...) which is why I switched to delete, this runs fine but the table doesn't get deleted...
    Any thoughts as to why this isn't working/how I can clear my table? I have thought of setting up a separate scheduled job to delete the table contents however I do also need to run the report several times with different parameters so this isn't an ideal solution.
    I have tried adding a select after my delete statement as I thought if it had something to display on the report it would have to look at it but this didn't make any difference.
    Any help will be much appreciated!
    Thanks
    Chris

    Thanks for that!
    I have had a go at this and I can see how it will work although I have limited access on the Crystal userid I have so will need to have the SP created as part of our nightly refresh script I think.
    Is there no way of getting crystal to run my delete statement otherwise?
    Thanks again
    Chris

Maybe you are looking for