June 9, 2011 at 8:26 am
Hi,
I have a few tables I'd like to add some primary keys to. The key would need to be made on three columns, one of which is a datetime column. Is it possible to make the primary key aspect of this column only look at the date? i.e. 'yyyy-mm-dd' instead of 'yyyy-mm-dd hh:mm:ss'?
June 9, 2011 at 8:37 am
You could change the datatype to date. Otherwise you need to another solution for a primary key.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 9, 2011 at 8:45 am
so you can only have 365 records per year(or really one record per day)?
that's what a primary key based on just the days would limit you to? does that sound right in your case?
Lowell
June 9, 2011 at 8:58 am
Thanks sean.
Lowell, the primary key would be on the date plus two other columns.
The scenario is capturing statistics for databases and a daily basis. The primary key would be Date,Server name, and database Name
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply