Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Data Warehousing / June 2005

Tip: Looking for answers? Try searching our database.

Truncate Statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Granville - 13 Jun 2005 15:00 GMT
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
Michael C# - 13 Jun 2005 19:19 GMT
... WHERE DatePart(month, [date_column]) = DatePart(month, GetDate())
or
... WHERE DatePart(month, [date_column]) = DatePart(month,
Current_Timestamp)

> Good day everyone
>
[quoted text clipped - 17 lines]
>
> Granville
Michael C# - 13 Jun 2005 19:23 GMT
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.

> ... WHERE DatePart(month, [date_column]) = DatePart(month, GetDate())
> or
[quoted text clipped - 22 lines]
>>
>> Granville
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.