user609511
user609511

Reputation: 4261

sql select with except in query

i got the item that i want to like this:

SELECT 
     ORDRE.NO_ORDRE
     ,ORDRE.CODE_CLIENT

  FROM [Soft8Exp_Client].[dbo].[ORDRE]  
      where DATEPART(YEAR,ORDRE.DATE_CLOTUR_REEL) = 2014
  and DATEPART(MONTH,ORDRE.DATE_CLOTUR_REEL) = 4
  and DATEPART(DAY,ORDRE.DATE_CLOTUR_REEL) = 29

 EXCEPT

  SELECT  
      [NO_ORDRE]     
      ,[CODE_CLIENT]   
  FROM [Soft8Exp_Client].[dbo].[LETTRE_VOIT]
    where DATEPART(YEAR,DATE_CLOTUR_REEL) = 2014
  and DATEPART(MONTH,DATE_CLOTUR_REEL) = 4
  and DATEPART(DAY,DATE_CLOTUR_REEL) = 29

now how can i put it into UPDATE command ?

   UPDATE [Soft8Exp_Client].[dbo].[ORDRE]
SET STATUS = 1
    WHERE ??

Upvotes: 0

Views: 282

Answers (1)

Mithrandir
Mithrandir

Reputation: 25337

I'm not quite sure, what you want to do. Do you want this?

 UPDATE [Soft8Exp_Client].[dbo].[ORDRE] o
 SET o.STATUS = 1
 FROM (
    -- Your query from the top of your question    
 ) t
 WHERE o.NO_ORDRE = t.NO_ORDRE AND o.CODE_CLIENT = t.CODE_CLIENT;

Upvotes: 1

Related Questions