Click here to Skip to main content
15,918,193 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i white q query fo Update :
SQL
UPDATE tblFavorite
SET 
tblFavorite.ItemID=tblFavoritetemp.ItemID,
tblFavorite.ItemTitle = tblFavoritetemp.ItemTitle,
FROM tblFavoritetemp  
WHERE
   tblFavorite.CategoryID = tblFavoritetemp.CategoryID AND IF (tblFavorite.ExDate <> null) begin  (DATEDIFF(minute, tblFavorite.ExDate, GETDATE())) <= 0         end


but giv error on : IF (tblFavorite.ExDate <> null)

it say : Incorrect syntax near the keyword 'IF'.
Msg 102, Level 15, State 1, Line 8
Incorrect syntax near 'DATEDIFF'.
__________________________
PLZ help me ...
Posted

Try This.

XML
UPDATE tblFavorite
SET
tblFavorite.ItemID=tblFavoritetemp.ItemID,
tblFavorite.ItemTitle = tblFavoritetemp.ItemTitle,
FROM tblFavoritetemp
WHERE
tblFavorite.CategoryID = tblFavoritetemp.CategoryID 
AND 
CASE WHEN (tblFavorite.ExDate <> null) THEN DATEDIFF(minute, tblFavorite.ExDate, GETDATE())) ELSE 0 END <= 0         


Hope this will help you.
 
Share this answer
 
SQL
UPDATE tblFavorite
SET
tblFavorite.ItemID=tblFavoritetemp.ItemID,
tblFavorite.ItemTitle = tblFavoritetemp.ItemTitle,
FROM tblFavoritetemp
WHERE
   tblFavorite.CategoryID = tblFavoritetemp.CategoryID
  CASE WHEN (tblFavorite.ExDate IS NOT NULL) THEN DATEDIFF(minute, tblFavorite.ExDate, GETDATE())) ELSE 0 END <= 0
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900