Solved

Default column value using default or formula properties

Posted on 2006-06-12
5
495 Views
Last Modified: 2010-05-18
I have a date column on my table defined as datetime (call_date) (not necessarily current date)

I also have 2 columns named  call_month and call_year ( both defined as varchar).

I would like the call_month and call_year values to be defaulted to month and year portions of call_date respectively.

Is it possible to do this using the default or formula values for the field definitions?


For example if call_date is 5/24/06....call_month would default to 5 and call_year would default to 06


I know I could do this using a trigger but just curious....
0
Comment
Question by:johnnyg123
  • 2
5 Comments
 
LVL 9

Expert Comment

by:raopsn
Comment Utility
Yes you can use a trigger to that,
but why you want to store that data ? when you can derive it at any time
0
 

Author Comment

by:johnnyg123
Comment Utility
I needed it to make it easier to do reporting .....actually...I figured it out


for call_month

(case when ([FOTCCallDate] is not null) then (datepart(month,[FOTCCallDate])) else '' end)


for call_year

(case when ([FOTCCallDate] is not null) then (datepart(year,[FOTCCallDate])) else '' end)


How can I close this case?
0
 
LVL 9

Expert Comment

by:raopsn
Comment Utility
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
Comment Utility
Closed, 500 points refunded.
Netminder
Site Admin
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now