Showing posts with label line. Show all posts
Showing posts with label line. Show all posts

Thursday, March 29, 2012

delete duplicate orders

I have an order with multiple line items. When the order comes in and put into a table I would like to check that they haven't submitted it twice. Right now I have a stored procedure that can find duplicate lines, but I really need if the whole order ha
s been duplicated then delete it.
So in my store procedure I use:
SELECT COUNT(*) AS Amount,ItemNumber,Store,DeliveryDate,submission,Qu antity
FROM tblItemOrder
GROUP BY ItemNumber,Store,DeliveryDate,submission,Quantity
HAVING COUNT(*) > 1
So this finds duplicate rows. But I need to find if the all rows are duplicated go ahead and delete.
The table structure is fields Amount,ItemNumber,Store,DeliveryDate,submission,Qu antity with no primary key (working table to get the data into shape).
Even if I could find if there are the same amount of rows that have duplicates COUNT(*) > 1, then go ahead and delete the duplicates that would work fine.
hi ashley,
See following example:
--sample data.
create table #cartype(manufacturer varchar(500), itemnumber int)
insert into #cartype values('Toyota',1)
insert into #cartype values('Toyota',1)
insert into #cartype values('Toyota',1)
insert into #cartype values('Honda',2)
insert into #cartype values('Honda',2)
insert into #cartype values('Honda',3)
insert into #cartype values('GE',3)
--deleting all duplicate rows from the table, query will be.
delete a
from #cartype a join
(select manufacturer, itemnumber
from #cartype
group by manufacturer, itemnumber
having count(*) > 1) b on a.manufacturer = b.manufacturer and
a.itemnumber = b.itemnumber
--if you want to keep one row out of the duplicate rows, you will have to
add an identity column to the table.
Ex:
alter table #cartype add idd int identity
--deleting duplicate rows from the table except one
delete from #cartype
where not exists
(Select * from #cartype a
where a.manufacturer = #cartype.manufacturer
and a.itemnumber = #cartype.itemnumber
having min(idd) = #cartype.idd)
--drop the temporary added column
alter table #cartype drop column idd
Vishal Parkar
vgparkar@.yahoo.co.in

Friday, February 17, 2012

Default Value - I see the finish line!

Third Posting on how the heck Report Manager sets the "Has Default" property,
specifically the method it uses. Current, RS drops that property when you
copy a report, hence making Snap Shots impossible when Snapping a copy of
another report. I'm doing this in an application.
Comon someone, I get this down and this baby gets thru QA!!!
My kingdom for the answer!!
thank you in advanceTake a look at
http://msdn.microsoft.com/library/en-us/rsprog/htm/rsp_ref_soapapi_ir_5zec.asp
for working with ReportParameter Objects
and
http://msdn.microsoft.com/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_48jc.asp
for how to call SetReportParameters method.
Some examples for working with report parms can be found on:
http://groups.google.com/groups?q=SetReportParameters&hl=en&lr=&group=microsoft.public.sqlserver.reportingsvcs&selm=OlRQmQDuEHA.3860%40TK2MSFTNGP09.phx.gbl&rnum=8
http://groups.google.com/groups?hl=en&lr=&frame=right&th=3c7cb0c51785eb58&seekm=9F17B95C-B484-46D9-A7F0-FD7BE91DE8EB%40microsoft.com#link7
Suspect you need to 1st call GetReportParameters against old report to
obtain parameters, then SetReportParameters against copy fo the report you
are making.
--
-- "This posting is provided 'AS IS' with no warranties, and confers no
rights."
jhmiller@.online.microsoft.com
"Eddie" <Eddie@.discussions.microsoft.com> wrote in message
news:6320E87B-95CA-4DA7-85FB-B2FCF05198E2@.microsoft.com...
> Third Posting on how the heck Report Manager sets the "Has Default"
> property,
> specifically the method it uses. Current, RS drops that property when you
> copy a report, hence making Snap Shots impossible when Snapping a copy of
> another report. I'm doing this in an application.
> Comon someone, I get this down and this baby gets thru QA!!!
> My kingdom for the answer!!
> thank you in advance|||John,
I do as the docs and you speak of. The twist is, you can't set a default
value if the report does not have the "has default" check box ichecked. It
works great if that darn check box is checked. Unfortunately, when you do a
Copy of a report, using CreateReport(), it for some reason loses the "Has
Default" property, meaning you can't progamatically set it, and hence, cannot
create a snapshot from it. I know it's possible, since you can do it in
Report Manager. What I can't figure out is how to progamatically set the "Has
Default" property of the parameter. The "Has Default" property is not listed
as a public of the ReportParameter Class.
"John H. Miller" wrote:
> Take a look at
> http://msdn.microsoft.com/library/en-us/rsprog/htm/rsp_ref_soapapi_ir_5zec.asp
> for working with ReportParameter Objects
> and
> http://msdn.microsoft.com/library/en-us/rsprog/htm/rsp_ref_soapapi_service_lz_48jc.asp
> for how to call SetReportParameters method.
> Some examples for working with report parms can be found on:
> http://groups.google.com/groups?q=SetReportParameters&hl=en&lr=&group=microsoft.public.sqlserver.reportingsvcs&selm=OlRQmQDuEHA.3860%40TK2MSFTNGP09.phx.gbl&rnum=8
> http://groups.google.com/groups?hl=en&lr=&frame=right&th=3c7cb0c51785eb58&seekm=9F17B95C-B484-46D9-A7F0-FD7BE91DE8EB%40microsoft.com#link7
> Suspect you need to 1st call GetReportParameters against old report to
> obtain parameters, then SetReportParameters against copy fo the report you
> are making.
> --
> -- "This posting is provided 'AS IS' with no warranties, and confers no
> rights."
> jhmiller@.online.microsoft.com
> "Eddie" <Eddie@.discussions.microsoft.com> wrote in message
> news:6320E87B-95CA-4DA7-85FB-B2FCF05198E2@.microsoft.com...
> > Third Posting on how the heck Report Manager sets the "Has Default"
> > property,
> > specifically the method it uses. Current, RS drops that property when you
> > copy a report, hence making Snap Shots impossible when Snapping a copy of
> > another report. I'm doing this in an application.
> >
> > Comon someone, I get this down and this baby gets thru QA!!!
> > My kingdom for the answer!!
> >
> > thank you in advance
>
>