Solved

Delete SQL statement

Posted on 2006-11-27
3
319 Views
Last Modified: 2012-05-05
I am using Query analyzer which i use to maipulate and update numerous database tables found on a server. I have a table with stock numbers e.g C87676-001 that also has numerous other columns, an example of one is the planner notes column. These stock numbers occur 2 or 3 times over and the copys have incomplete information that needs to be deleted. e.g. One entry of C87676-001 may have all information available in the columns then the next entry of C87676-001 may have the same info in every column except the planner notes column when it has a NULL value. This record will be the one that we delete.

I used the following statement

DELETE FROM dbo.vw_linc_mrp
WHERE Stock_Nbr like 'C87676-001' AND [Planner notes] like 'NULL'

this should work though in this case i get the following error....


The view or function 'dbo.vw_linc_mrp' is not updatable because the definition contains the TOP clause.

ideas on how to help?
0
Comment
Question by:ward20
3 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 18019799
IS 'dbo.vw_linc_mrp' a table ?

SELECT * FROM iNFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'vw_linc_mrp'
0
 
LVL 77

Expert Comment

by:arnold
ID: 18019809
try
select * from dbo.vw_linc_mrp
WHERE Stock_Nbr like 'C87676-001' AND [Planner notes]=NULL

To see whether the rows you want deleted are returned.

prior to:
DELETE FROM dbo.vw_linc_mrp
WHERE Stock_Nbr like 'C87676-001' AND [Planner notes]=NULL
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18019830
as from the error message, the view is not updatable.
if the view returns the primary key informations, you can do this:

delete from yourtable
 where keyfield in ( select keyfield from  dbo.vw_linc_mrp
WHERE Stock_Nbr like 'C87676-001' AND [Planner notes] like 'NULL'
 )
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question