Solved

Delete SQL statement

Posted on 2006-11-27
3
321 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 78

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 143

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Read about achieving the basic levels of HRIS security in the workplace.
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
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…

738 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