Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delete SQL statement

Posted on 2006-11-27
3
Medium Priority
?
326 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 80

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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

609 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