Register and join over 40,000 other developers!
Recent Topics
-
The Game You Are Waiting For?
WendellHarper - Dec 06 2020 01:21 PM
-
Quora and Reddit Backlinks
WendellHarper - Dec 06 2020 01:14 PM
-
Delete account
pindo - Jul 23 2020 01:33 AM
-
Print specific values from dictionary with a specific key name
Siten0308 - Jun 20 2019 01:43 PM
-
Learn algorithms and programming concepts
johnnylo - Apr 23 2019 07:49 AM
Recent Blog Entries
Recent Status Updates
Popular Tags
- networking
- Managed C++
- stream
- console
- database
- authentication
- Visual Basic 4 / 5 / 6
- session
- Connection
- asp.net
- import
- syntax
- hardware
- html5
- array
- mysql
- java
- php
- c++
- string
- C#
- html
- loop
- timer
- jquery
- ajax
- javascript
- programming
- android
- css
- assembly
- c
- form
- vb.net
- xml
- linked list
- login
- encryption
- pseudocode
- calculator
- sql
- python
- setup
- help
- game
- combobox
- binary
- hello world
- grid
- innerHTML

15 replies to this topic
#1
Posted 21 June 2012 - 05:19 PM
I'm asking MSSql questions here since I'm using C# for my project. There's a lot of datatypes for some string but I'm interested only in few of them. What datatypes and their length I should use for Name, Surname, E-mail and Comments on something. I was googling it but every site gave me different answer, so I am confused.
Microsoft Student Partner, Microsoft Certified Professional
#2
Posted 21 June 2012 - 07:06 PM
I think you should have posted this topic in database programming section.
If you are sure about or if you will give restriction to your users to input a maximum number of characters, you can use nvarchar(n) where n is the maximum number of characters you want to your users be able to input. Same for comments.
But if you don't want to apply restrictions, you can use nvarchar(max) type, however it has also an storage limitation of 2 GB!
Note, nvarchar is to support unicode. If you are sure you are not going to support unicode or your user will not input unicode, you can use varchar type instead of nvarchar.
For comments column, you can also think about text/ntext.
If you are sure about or if you will give restriction to your users to input a maximum number of characters, you can use nvarchar(n) where n is the maximum number of characters you want to your users be able to input. Same for comments.
But if you don't want to apply restrictions, you can use nvarchar(max) type, however it has also an storage limitation of 2 GB!
Note, nvarchar is to support unicode. If you are sure you are not going to support unicode or your user will not input unicode, you can use varchar type instead of nvarchar.
For comments column, you can also think about text/ntext.
#3
Posted 22 June 2012 - 06:52 AM
Yes, unicode support is what I need because of Croatian alphabet. But what I want to know is from your experience what should be maximum length of nvarchar for name, surname and e-mail?
Microsoft Student Partner, Microsoft Certified Professional
#4
Posted 22 June 2012 - 07:25 AM
Sorry to say that I'm not an expert with MSSQL. But I as I said, you can set a constraints about the maximum length of name/surname/email on the UI where user will input those fields and you can set that maximum size to the database too. This post may come in help for you. Take a look into these two too -- post1 and post2.
#5
Posted 22 June 2012 - 11:45 AM
ok you helped me for e-mail, but what about name field and surname field?
Microsoft Student Partner, Microsoft Certified Professional
#6
Posted 22 June 2012 - 02:23 PM
ok you helped me for e-mail, but what about name field and surname field?
the name and surname field depends on you, in my case I'm putting a 30 or 50 length into a name and a 30-50 length also in surname because there are some names that is so long... but it's good to limit the characters allowed in a given field to save some database memory
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped
Never Forget To HIT "LIKE" If I Helped
#7
Posted 22 June 2012 - 03:18 PM
ok thank you very much
Microsoft Student Partner, Microsoft Certified Professional
#8
Posted 23 June 2012 - 12:12 AM
For variable length of chars, actually there is not much difference of performance or space saving between max length of 20 (for example) with 50 (the usual default max length). Unless there is another business rule you have to follow in other area, you can safely use 50 for max chars length for names.
#9
Posted 23 June 2012 - 08:22 AM
just another theory question. I'm working with MDF file that I have created in Visual Studio, not in MSSql Server 2008. I'm wondering, if I want to store older datas from one Data Table, what should I do? I mean, there can be a 2 records that contain the same Name, but new record contains different values in the same Data Table, how can I show all datas from that person and how can I show the newest data from that person? Can I do it from primary key from that table or there is other method?
Microsoft Student Partner, Microsoft Certified Professional
#10
Posted 23 June 2012 - 08:38 AM
Tonchi, I'm not sure about your question. Can you please explain a bit with example?
#11
Posted 23 June 2012 - 08:46 AM
I was thinking that I didn't explain it well. So...Imagine that you are working in the school as a teacher. Insteaed of stupid grade books you have a small application for managing the grades of each student. Now, during the school year you are entering the grades for students. After the year has ended, you want to see every single grade from every / one student. I have indetical problem, but not for a students 
Now if I'm using update statement in my database, my previous records would be deleted. Correct me if I am wrong. I don't want of those records to be deleted, I want to see them all in one table in application.
I hope that I have clear that

Now if I'm using update statement in my database, my previous records would be deleted. Correct me if I am wrong. I don't want of those records to be deleted, I want to see them all in one table in application.
I hope that I have clear that

Microsoft Student Partner, Microsoft Certified Professional
#12
Posted 23 June 2012 - 08:59 AM
I think I understand this part correctly. Now,I was thinking that I didn't explain it well. So...Imagine that you are working in the school as a teacher. Insteaed of stupid grade books you have a small application for managing the grades of each student. Now, during the school year you are entering the grades for students.
Well, after that year ended I can see the grades of every student by the query 'SELECT * FROM students;' where students is the table name.After the year has ended, you want to see every single grade from every / one student. I have indetical problem, but not for a students
WIth the SQL UPDATE query, you are about to update the records that you want to intend to with the conditions in the UPDATE query (please see example here). What do you mean by the previous records will be deleted?Now if I'm using update statement in my database, my previous records would be deleted. Correct me if I am wrong. I don't want of those records to be deleted, I want to see them all in one table in application.
Sorry, I'm still not sure about your goal.
Also tagged with one or more of these keywords: mssql
Language Forums →
PHP →
mssql_connect() Unable to connect to server to Remote host from php hostingStarted by saweff, 14 Nov 2016 ![]() |
|
![]() |
||
Language Forums →
C and C++ →
Out of date Libraries? Not quite sure whats going on.Started by xXAlphaXx, 05 Jun 2014 ![]() |
|
![]() |
||
Language Forums →
C# →
Get Identity immediately and enter it to different table with other informationStarted by innocence, 31 May 2014 ![]() |
|
![]() |
||
Language Forums →
Databases →
MSSql -> normaln thing or a bugStarted by Tonchi, 03 Jul 2013 ![]() |
|
![]() |
||
![]() pl help i need ms access transform statement in mssql urgentStarted by viveq, 04 Jun 2013 ![]() |
|
![]() |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download