all groups > sql server data warehouse > june 2005 >
You're in the

sql server data warehouse

group:

Truncate Statement


Truncate Statement Granville
6/13/2005 7:00:05 AM
sql server data warehouse: 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
Re: Truncate Statement Michael C#
6/13/2005 2:19:43 PM
.... WHERE DatePart(month, [date_column]) = DatePart(month, GetDate())
or
.... WHERE DatePart(month, [date_column]) = DatePart(month,
Current_Timestamp)


[quoted text, click to view]

Re: Truncate Statement Michael C#
6/13/2005 2:23:29 PM
FYI, it will be a little more complex than this since you want to reference
the dates from another column in another table, but the general idea is use
the DatePart(month, ...) to get the month out of a date. Thanks.

[quoted text, click to view]

AddThis Social Bookmark Button