TRUNCATE TABLE applies to the whole table only. You can't apply a where
clause with a TRUNCATE TABLE.
For what you want to do you need to use DELETE, something like:
DELETE d
FROM data d
INNER JOIN time t1
ON d.day = t1.day
INNER JOIN time t2
ON t1.Month = t2.Month
AND t1.Year = t2.Year
WHERE t2.day = CONVERT(CHAR(

, GETDATE(), 112)
--
Jacco Schalkwijk
SQL Server MVP
"Granville" wrote in message
> Good day everyone
>
> I have two SQL tables. One is a "Data" table in it with the days in the
> dd/mm/yyy format.
>
> Another "Time" table has the
> dd/mm/yyy , Month, Quarter , Year in it.
>
> I want to truncate the "Data" table but only where the Month is equal to
> current month.
> Rather than putting in a string "manually" I want the truncate statement
> to
> pick up today's date, look in the "Time" table, pick up the month that
> current day belongs to and truncate all those days out of the "Data"
> table.
>
> I've not even started so any ideas will be welcomed?
>
> Thanks
>
> Granville
> >> Stay informed about: Truncate Question