September 20, 2011 at 8:48 am
Please help me out on the data types and length- I have to create the sql table and the columns and data are listed below. I am not sure about the datatype and length. Can you please help me?
ColumnNameData
Milstone_NumberMilestone #1
S_Objective1. A Nat System Must Be band at the Community Level
Project_NameA. Develop Protect-Prep Comm
Project_Item1.1.A
September 20, 2011 at 8:56 am
It depends on your business requirements, not on what someone else might think based on a very, very small data sample.
They all look like strings so a varchar would be as good as any, as for length well, who knows? Anywhere from 5 to 65.
September 20, 2011 at 9:05 am
The data is sample is in bracket (Milestone #1), (1. A Nat System Must Be band at the Community Level)
(A. Develop Protect-Prep Comm), (1.1.A ) and you are saying varchar??
September 20, 2011 at 9:10 am
What data types are you planning on inserting into the table? If you know that, you should be able to answer your own question 🙂
If you're allowing users to input free type, what is the maximum length of the field they're inputting data into?
Varchar seems like the way forward, but if you can't be certain of the data going in (and this table isn't going to extend to a billion rows!), I'd recommend making it as wide as possible.
_____________________________________________________________________
Disclaimer - The opinions expressed by the mouth are not necessarily those of the brain
September 20, 2011 at 9:18 am
hydbadrose (9/20/2011)
The data is sample is in bracket (Milestone #1), (1. A Nat System Must Be band at the Community Level)(A. Develop Protect-Prep Comm), (1.1.A ) and you are saying varchar??
Yes, I can see the data. The problem is this is a very small sample dataset (unless you only going to insert one record into your table).
Yes, varchar would be a valid type. But from your sample data there is no way to tell what suitable lengths for the columns might be. Only proper analysis will tell you that, we cannot guess!
September 20, 2011 at 9:23 am
Given your sample this will tell you your column widths: 🙂
SELECT LEN('A Nat System Must Be band at the Community Level'),
LEN('Milestone #1'),
LEN('A. Develop Protect-Prep Comm'),
LEN('1.1.A')
:w00t:
September 20, 2011 at 9:56 am
For Project_Item 1.1.A I was thinking to use float.
September 20, 2011 at 10:01 am
hydbadrose (9/20/2011)
For Project_Item 1.1.A I was thinking to use float.
[1.1.A]
it has two periods and the letter "A" in it...it would have to be a varchar.
Lowell
September 20, 2011 at 10:01 am
hydbadrose (9/20/2011)
For Project_Item 1.1.A I was thinking to use float.
But '1.1.A' is not a valid float its got an 'A' in it. Since when was 'A' a valid digit?
September 20, 2011 at 10:10 am
Thanks!
September 20, 2011 at 12:01 pm
When in doubt you should consult the datatypes and what they can handle. http://msdn.microsoft.com/en-us/library/ms187752.aspx
_______________________________________________________________
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/
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply