TSQL code that causes table data to be deleted rather than fail with a compilation error

Afternoon,
I recently did this by accident and it felt as though it should have failed with a compilation error rather than run
A query of the form
delete from jobs
where id in
select id from calibrations
will delete all rows in the jobs table when the id column exists in the jobs table, but not the calibrations table. This should fail with a compilation error.
the following sql can be used to generate a test database to show the problem
USE [test]
GO
/****** Object:  Table [dbo].[calibrations]    Script Date: 28/11/2014 13:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[calibrations](
    [JobId] [int] NULL,
    [textfield] [nvarchar](50) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[jobs]    Script Date: 28/11/2014 13:32:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[jobs](
    [Id] [int] NOT NULL,
    [Name] [nchar](10) NULL
) ON [PRIMARY]
GO
INSERT [dbo].[calibrations] ([JobId], [textfield]) VALUES (1, N'something')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (1, N'a         ')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (2, N'b         ')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (3, N'c         ')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (4, N'd         ')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (5, N'e         ')
GO
INSERT [dbo].[jobs] ([Id], [Name]) VALUES (6, N'f         ')
GO
Simon
simon

will delete all rows in the jobs table when the id column exists in the jobs table,
but not the calibrations table. This should fail with a compilation error.
Hello Simon,
That's a bug in your T-SQL Statement, not in SQL Server. The Statement as it is valid and column "id" exists, so why should it fail on compilation?
And that is the reason why we always should use full qualified object name, e.g. like
delete from jobs AS J
where J.id in
select SUB.id from calibrations AS SUB
and this Statement should fail on compilation.
Olaf Helper
[ Blog] [ Xing] [ MVP]

Similar Messages

  • Simple AS3 code that causes 10.2 to crash

    Very simple code that causes flash 10.2 to crash on all platforms.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="300" minHeight="200">
         <fx:Script>
              <![CDATA[
                   import mx.controls.Alert;
                   private function crash(type:int, ...additionalArgs):void {
                        var msg:String;
                        switch (type) {
                             case 1: msg = "Crashes!"; break;
                             case 2: msg = additionalArgs[0]; break;
                        Alert.show("Crash : " + msg);
                   private function notCrash(type:int, ...additionalArgs):void {
                        // Does nothing at all, but stops the crash....
                        if (additionalArgs) {}
                        var msg:String;
                        switch (type) {
                             case 1:msg = "Not crash"; break;
                             case 2: msg = additionalArgs[0]; break;
                        Alert.show("NotCrash : " + msg);
              ]]>
         </fx:Script>
         <s:Button label="Does not crash flash" click="notCrash(2,'value')" x="10" y="10"/><s:Button label="Crash flash" click="crash(2,'value')" x="150" y="10"/>
    </s:Application>

    hkudo wrote:
    mike_brewer,
    Thank you for reporting the bug. We will take a look at this bug asap.
    thanks,
    Hitomi
    FP/AIR team
    Hi Hitomi
    Thank you! Finally someone is looking into this.
    I have also submitted a bug report on your site about this issues.
    Currently for the developers there is a simple workaround; which is to wrap the switch statement that uses a rest parameter in a try/catch. This
    prevents the crash even though the catch statement is reached!
    I have also have another forum post that goes into more detail about this :
    http://forums.adobe.com/thread/795395?tstart=0
    Regards Michael

  • Changes will cause the data to be deleted message is misleading

    We find that the message 'Changes will cause the data to be deleted' is misleading and causes a great deal of concern to our users when it appears say when they are just trying to find information and are browsing from one transaction to another. Is there anyway we can get this message amended for certain scenarios at least?

    Sam,
    someone asked this few days ago.
    [look here|Is It Possible to block system message;
    i suggested to catch the statusbar and Petr suggested to catch the Event and click it away with sending "enter"
    thats it - i hope it helps
    regards
    David
    PS: Welcome to the Forum

  • Windows 2008 R2 backup fails with event 521 error code 2155348001

    Windows Server 2008 R2 SP1.  Hyper-V role installed. 
    OS on drive C.  All VMs stored on Drive D.
    I am attempting to run a Bare Metal backup of the host system to a network share. 
    Drive D is not included in the backup job.  I am getting the following error:
    Log Name:      Application
    Source:        Microsoft-Windows-Backup
    Date:          1/10/2014 11:28:52 PM
    Event ID:      521
    Task Category: None
    Level:         Error
    Keywords:     
    User:          SYSTEM
    Computer:      SHAQTUS.scdl.local
    Description:
    The backup operation that started at '‎2014‎-‎01‎-‎11T04:08:50.683000000Z' has failed because the Volume Shadow Copy Service operation to create a shadow copy of the volumes being backed up failed with following error code '2155348001'. Please review the event
    details for a solution, and then rerun the backup operation once the issue is resolved.
    Reviewing event details, as suggested, does not offer any solution.
    I have tried the suggested solutions in other similar threads of increasing the timeout value with the registry entry. 
    This does not work.
    I have not tried reregistering the VSS writers manually, as the only links I have found are for server 2003/2008 (not R2) and explicitly state that they won’t work on higher versions of the OS, since they now utilize manifests and the manual procedure could
    cause problems for those servers. Haven't found similar procedures for 2008 R2.
    I have been able to narrow this down a bit.
    A Windows 2008 R2 SP1 server with Hyper-V installed – backup to a network share is successful;
    Install the DPM 2012 agent – same backup fails with the 2155348001 error.
    We use DPM 2012 to backup VMs, but DPM cannot perform a bare metal backup/restore of server and the 2012 version no longer has the DPMSRT feature. 
    I prefer to run Bare Metal Backup to a file server share.
    Stuck on this one.
    Rick

    Hi, 
    The issue is related to DPM, I would suggest you ask for help from DPM forums:
    http://social.technet.microsoft.com/Forums/en-US/home?forum=dataprotectionmanager
    Regards, 
    Mandy
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Processing data for a remote command failed with the following error message: Error occurred during the Kerberos reponse.

    Hi!
    We have 5 Exchange 2013 servers and when I’m trying to run a script that includes the cmd-let Get-MessageTrackinglog with StartDate = the first of the month and with EndDate = the end of the month I get the following error message after
    a couple of hours. The script is run on the server SERVER01 and goes through the Message Tracking logs of all Exchange servers. I have tried the script on other servers and get the same result.
    Processing data for a remote command failed with the following error message: Error occurred during the Kerberos reponse.
    [Server=SERVER01, TimeStamp = 918/2014 19:32:34]
    For more information, see the about_Remote_Troubleshooting Help topic.
        + CategoryInfo         
    : OperationStopped: (server01.domain.com:String) [], PSRemotingTransportException
        + FullyQualifiedErrorId : JobFailure
        + PSComputerName       
    : server01.domain.com
    I have gone through “about_Remote_Troubleshooting Help topic”, but can’t find anything related to my issue. There is nothing in the Application or the Windows PowerShell log either.
    /Henrik

    Hi Henado 
    Check the time on your Exchange server(s) relative to the DCs and ensure they are in correct sync
    Use another account which is assigned the Organization Management permission and log to to the server run the command in shell and see the results
    Run 
    Add-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010
    Set-Adserversettings -ViewEntireForest $True and then run message tracking command and see the results
    If none of the above helps you may need to remove and re-install the WinRM and see the results
    Good Luck :)
    Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.That will encourage me - and others - to take time out to help you Check out my latest blog posts on http://exchangequery.com

  • If I purchase lightroom but want to install on both a pc and a mac is that possible from just a download version rather than ordering a disc?

    If I purchase lightroom but want to install on both a pc and a mac is that possible from just a download version rather than ordering a disc?

    Yes, a single serial number can be used to install on two computers and one can be a PC and one a Mac.   The download will be a different installer for each platform but the serial number should activate both.

  • When I load itunes it defaults to the store and then I get a Blue Screen.  Does anyone know how to change itunes so that it will default to My Music rather than store.  I need to be able to do this before I load itunes.

    When I load itunes it defaults to the store and then I get a Blue Screen.  Does anyone know how to change itunes so that it will default to My Music rather than store.  I need to be able to do this before I load itunes.

    I solved the problem with the assistance of apple support knowledgebase.  Refer to TS3441.

  • I can't change my imessage so that it goes through my mobile number rather than my email

    I can't change my imessage so that it goes through my mobile number rather than my email
    For some unknown reason, my phone has decided to change my imessage reciever to my email rather than my actual mobile number and won't let me change it back

    Hi, i have had this same problem a few times, but i think i found a solution.
    Go into your setting to iMessage, disable it from your email, via logging out of it using your Apple iD
    So now ita only your phone number on iMessage.
    At first it wont work, but try turning it off and on, just give it abit of time until it registers that your number is able yo use iMessage.
    Once you notice its working, just go back and log back into using your Apple iD
    Hope it Helps
    Ryan.

  • How to restarting code that caused exception?

    Hello all,
    Suppose we have handled an exception in a catch block. Is there anyway we can restart the line that caused the exception?
    For example:
    try {
    System.out.println("here"); // this line should be executed only once
    a = b / c // we want to execute this line again if an exception occurs
    catch(Exception e) {
    c = 0.01;
    // OK, we have now corrected the problem (division by 0). How can we
    // restart the offending line (a = b / c) in the try block?
    Thanks for any help!
    -Kamran
    [email protected]

    You can put the offending portion of code in its own block:System.out.println("here");
    try {
             a = b / c // we want to execute this line again if an exception occurs
    catch(Exception e) {
        a = b / 0.01;
    System.out.println("and here");And possibly eliminate the try-catch mechanism completely:System.out.println("here");
    c = (c == 0) ? 0.01 : c;
    a = b / c;
    System.out.println("and here");

  • HT4859 How can I verify that my App data is actually stored in iCloud. With Dropbox, I can actually see my stored files. With iCloud, itseems I'm supposed 2 just trust that Appl has the data. Short of doing a restore is there no way to check the data?

    How can I verify that my App data is actually stored in the iCloud. I can see and access my notebook, contacts etc. on the iCloud website, and I can see my photos in a folder on my Windows-based desktop compter (iCloud/Photostream). But no app data.
    With Dropbox, I can actually see all of my stored files. With iCloud, it seems, I'm supposed to just trust that Apple has my back. Short of deliberately trashing my app data and then attempting a restore, is there no way to check the data?

    You can't access them on Windows (unless you have iCloud enabled Windows programs) and I don't think any are, yet.
    iCloud data is accessed via Apps/Programs, the Windows programs vendors will have to step up (just to make it worse Microsoft have not yet enabled their Mac programs, such as Office yet) I doubt that iCloud access is much of a priority for them, complain to MS, when enough Windows users complain maybe they'll do something.

  • View with SAP tables fails with "No Owner" error

    Dear experts,
    We have created a view (VIEW_MARA_MAKT) on Information Steward (4.2 SP1) using SAP tables MARA and MAKT.  This view is working perfectly.  Next we create another view to join with our previous view (VIEW_MARA_MAKT) to table MARC.  The view validates correctly, but when trying to view the data we get the following error:
    Data Services execution failed for VIEW_MATERIAL_PLANT. Error :
    (14.2) 04-08-14 12:46:21 (E) (0432:6996) RES-020106: |SESSION JOB_VView_736_43f3f6da_b863_46d6_ad64_b4f432a939b0|DATAFLOW EABAPDF_VIEW736_0|STATEMENT <GUID::'4a0dddf9-c993-4577-9e9a-1e0adf2dc9e2::794ee432-24f4-4801-bccf-587ef489e934::65e45615-06f8-426f-abf2-61345f6c252f' READ TABLE ICCDS_21."".MARC OUTPUT(IS_VIEW_RDR_475_0)> Table <MARC> for owner <> was not found in the repository for datastore <ICCDS_21>. Import this table from the external source. If the name is case-sensitive in the database (and not all uppercase), enter the name as it appears in the database and use double-quotation marks around the name to preserve the case. (COR-10690)
    It appears that DS is not satisfied that there is no owner name sent from IS, but for SAP connections it is not possible to specify owner names when adding the tables to IS.
    Please can you give some recommendations to resolve this error.

    What you can do is to use a table of record.
    And create a block based on stored procedure.
    Below is a table of record and procedure for querying from multi-tables.
    If you want to update, insert, delete rows, you need to create 3 more procedures on the package. One for updating, another for inserting, and so on.
    I never done updaing part before. So I need to spend time for coding.
    If you want, I can post later as soon as I got it.
    CREATE OR REPLACE PACKAGE TEST5 AS
    TYPE REC1 IS RECORD (FIRST TEST1.FIRST%TYPE,
    SECOND TEST1.SECOND%TYPE,
    THIRD TEST2.THIRD%TYPE);
    TYPE TAB1 IS TABLE OF REC1 INDEX BY BINARY_INTEGER;
    PROCEDURE TEST1CREATE (P_TAB IN OUT TAB1);
    END;
    CREATE OR REPLACE PACKAGE BODY TEST5 AS
    PROCEDURE TEST1CREATE(P_TAB IN OUT TAB1) IS
    CURSOR C IS
    SELECT A.FIRST,A.SECOND,B.THIRD
    FROM TEST1 A, TEST2 B
    WHERE A.FIRST=B.FIRST;
    i NUMBER:=0;
    BEGIN
    OPEN C;
    LOOP
    EXIT WHEN C%NOTFOUND;
    i:=i+1;
    FETCH C INTO P_TAB(i).FIRST,P_TAB(i).SECOND,P_TAB(i).THIRD;
    END LOOP;
    END TEST1CREATE;
    END;
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Hercules:
    <HR></BLOCKQUOTE>
    null

  • Table Maintenance Generator-Before Delete event not working with sort

    Hi All,
    I have requirement to sort the TMG for a custom table with non primary key and also to put condition for deleting entries, so that only specific entries can be deleted.
    I did the sorting by adding MODULE SORT in the PBO of the Screen and providing the logic to sort EXTRACT and TOTAL tables with the required field. This is working correctly.
    Also I used BEFORE_DELETE (Event 03) to unmark all entries selected, which is not satisfying the condition. This is also working as expected.
    But, though they are working independently, these changes are not working together.
    Please help me in resolving this issue.
    Thanks,
    Savitha

    Hello,
    Read my answer on this thread :
    Maintenance View with Subset Fields
    I think It can help you about finding examples for table maintenance events
    and solution to your problem.

  • VideoPlayer.aspx page--how to add an element on page that allows to "Link to a Document" rather than "Add New Document"

    Hi All,
    We have SharePoint 2013 and are setting up a Video Library. The Video Player page is great, but rather than adding documents to this page, and have them go into a folder called "Additional Content" we would like to add an element to the page that
    would allow us to link to documents already on SharePoint so if something gets updated, then we don't have to worry about uploading documents in both places. However, because this is a Document Set, if I add a web part to the page (Content Query in this case)
    and then filter documents to the content query--it applies the content query and its filter to every single video's video player page.
    Anyone know of a way around this?

    Hi,
    According to your description, you might want to enable users add the links to documents in SharePoint Libraries in the “videoplayerpage.aspx”.
    The available OOTB features won’t be capable of your requirement, a possible workaround is that we can use JavaScript with JavaScript Client Object Model to achieve it programmatically.
    With JavaScript, we will be able to generate the controls needed in the “videoplayerpage.aspx” to provide users the abilities to get a link to a file in a SharePoint Library and
    display all the selected links in the current page;
    With JavaScript Client Object Model, we can save/read/update the related links of different video files in an extra list based on the ID of a video file. Also, it will enable us
    to query all the documents in all libraries in the current site.
    More information about JavaScript Client Object Model:
    How to: Create, Update, and Delete List Items Using JavaScript
    http://msdn.microsoft.com/en-us/library/office/hh185011(v=office.14).aspx
    Common Programming Tasks in the JavaScript Object Model
    http://msdn.microsoft.com/en-us/library/office/hh185015(v=office.14).aspx
    About how to
    modify the HTML source of a page using JavaScript:
    http://www.w3schools.com/js/js_htmldom_html.asp
    http://njarb.com/2011/06/update-html-content-using-javascript/
    It won't be an easy job to make all these things working together, therefore, a fact you might want to take into consideration is that more time and effort would be required to
    make it works.
    Feel free to reply if there any question about my suggestion.
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
    contact [email protected]
    Patrick Liang
    TechNet Community Support

  • Code to export table data into XL

    Hi experts
                      I am creating a WD application. In which i have a table and I want data of table to transported to a XL file . can it be possible in WD java. If it is , kindly give me code sample .
    Thanks in advance .
    Regards
    Abhay

    Hi ,
    tyr this blog
    /people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities
    Regards,
    Sudhir

  • Dynamic table data isn't transfered to the context, with webdynpro for java

    Hi,
    I'm using LifeCycle designer 7.1 and Adobe reader 7.0.5.
    I'm trying to make a dynamic table in a PDF form, that will be related to a table in the context.
    I've designed the context like it says here: Dynamic Table -  same data repeating in all rows
    I made a dynamic table and related the cells on the row to the context, by dragging the variables from the DataView into them.
    The table is related to TableList, the row to TableWrapper[], and the cells are related like this: TableData[].ItemName
    And there's a button which adds a row to the table.
    And for some reason, that's not working; When hitting the Submit to SAP button, it doesn't appear as though the data was transferred to the WebDynpro context.
    Can anyone help me with it please..?
    By the way - I tried using the SAP standard subform controls, the 'Insert Remove Move' control.
    When trying it through the PDF preview, it doesn't work - whatever I click displays an error message, and when it runs from the browser - It automatically searches for an update for Adove Reader (I use 7.0.5).
    Is it supposed to work only with version 8 of the Adobe Reader?

    Well, I reinstalled ACF, and now the Submit button works, and the Insert Remove Move buttons work as well.
    But the table context still doesn't work.
    I had put some values in the context, in DoInit, and they appeared in the table in the form, but when I changed them in the form it didn't affect the context at all.
    There's a simple attribute value related to a text field, which IS affected when changed in the form, and the Submit button is clicked. Only the table doesn't work.
    How can I make it work?
    Thanks,
    Udi Dekel

Maybe you are looking for