Print Page | Close Window

Data Types in SQL Server

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=12001
Printed Date: 30 March 2026 at 7:16am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Data Types in SQL Server
Posted By: Misty
Subject: Data Types in SQL Server
Date Posted: 01 October 2004 at 1:28am

What kind of data type should I use in a SQL Server database for the following:

1.) Yes/No field

2.) Memo field

 




Replies:
Posted By: Mart
Date Posted: 01 October 2004 at 2:51am
A boolean (Yes/No or True/False) can be a bit field. Then when you get the field with your asp.net page you need to use CBool() e.g.

Dim MyBoolean As Boolean = CBool(ds.Tables(0).Rows(0).Item("MyBoolean"))

because bits are stored as 1's and 0's.

For a memo field you can either use a varchar with a high length (that way you can compare and search the contents of the field) or you could use a Text field which has some massive length (but you can't compare or search the field)... It depends on what you want to do really and how big you want the field to be.


Posted By: theSCIENTIST
Date Posted: 01 October 2004 at 2:57am
For Yes/No and for all boolean types I use the bit type which will store (1/0) and can be checked against True/False.

Memo, use text type, then give it a lenght as needed, 8 for long memos and give it 16 for very long memos.

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com


Posted By: michael
Date Posted: 01 October 2004 at 9:32am
DOn't know where you heard that. Text can hold 2{30}-1 characters, there is only one text type. The data size is always 16 and represents just a pointer to the external (not stored in the table) 8KB pages of text data.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: theSCIENTIST
Date Posted: 01 October 2004 at 4:04pm
You are right, text always looked wierd to me now I know why, funny I used text with sizes <> 16, maybe some old SQL server version, not sure, I also prefer varchar's, more easily digestable.

So what would be the perfect scenario to use text types? Thx.

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com


Posted By: michael
Date Posted: 02 October 2004 at 12:47pm
text are generally blob fields. varchar is limited to 8000 charachters so whenever you need to store more, you'll go with text.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: Misty
Date Posted: 14 October 2004 at 7:18pm
I am trying to figure out something about the datatype, bit. Is 0 actually equal to true? Is 1 actually equal to false?


Posted By: Gullanian
Date Posted: 14 October 2004 at 7:57pm
I think it's the other way round.  Test it in your application is probably the best way to find out.

Heres a good article on data types in SQL Server:
http://www.sql-server-performance.com/datatypes.asp

Varchar is a good one to use if you are under 8,000 characters as it only takes up the space it uses (it doesn't take 8,000 character spaces up for each record if you only store 3 characters)


Posted By: Misty
Date Posted: 14 October 2004 at 9:13pm

Gullanian,

Thank you for the link to the SQL Server article! I tested my ASP.net Page. I found out that when I put the code for displaying the email addresses where "ShowEmail" was False, the web page displayed the email addresses that had the "ShowEmail" field of 1. I thought that 0 was false and 1 was true too.



Posted By: Gullanian
Date Posted: 14 October 2004 at 10:57pm
There you go then 

Best way to know the results in your environment is to test it in your environment.


Posted By: Misty
Date Posted: 23 October 2004 at 5:10pm

I need to correct a mistake that I made in an earlier posting.

Originally posted by Misty Misty wrote:

Gullanian,

Thank you for the link to the SQL Server article! I tested my ASP.net Page. I found out that when I put the code for displaying the email addresses where "ShowEmail" was False, the web page displayed the email addresses that had the "ShowEmail" field of 1. I thought that 0 was false and 1 was true too.

I found out that 0 is actually false and 1 is true. 




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net