Solved

Delete SQL statement

Posted on 2006-11-27
3
318 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
Comment Utility
IS 'dbo.vw_linc_mrp' a table ?

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

Expert Comment

by:arnold
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MySQL going to sleep 4 62
MySQL 11 66
Access Database - Manually changing xid value 7 44
Trouble connecting to SqlServer database 4 29
Creating and Managing Databases with phpMyAdmin in cPanel.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now