Top . comp . databases . ms-sqlserver
 Group:   comp.databases.ms-sqlserver Post new message ]   
  Author:   Plamen Ratchev
  Subject:   Re: Stored procedure Question
  Body:   I really do not understand what you are trying to do. It will be best to
post your complete table structures, insert statements to populate
sample data, and describe what are the desired results.

The error message should tell you what is the invalid column name. Seems
to me the first query will not accomplish much as you are grouping on
all columns. Plus not sure if you already have added the week_start_date
column which is essential for it to work.

You do not have to list any columns in the delete statement, it can be
as simple as this:

WITH Dups
AS
(SELECT COUNT(*) OVER(PARTITION BY pan) AS cnt
  FROM ClearedDiaries)
DELETE Dups
WHERE cnt > 1;

-- 
Plamen Ratchev
http://www.SQLStudio.com
  Topic:   Stored procedure Question
  Message:     Author     Date  
   *Message 1*     Plamen Ratchev     Fri, 10 Oct 2008, 11:55 am  
 Top . comp . databases . ms-sqlserver

 
Web news-reader.org
  Search this group:

Original PHP newsreader code from www.linuxnews.pl