TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Florin Bombeanu
NA
5
0
best practice for Saving boolean in SQL Server
Nov 15 2010 10:50 AM
Hi,
I would like to save a boolean value into a SQL Server table and retrieve in C# code. I think the best way to do this is to make the column type 'bit' and fill it with 1's and 0's but I would like to avoid explicit cast in my code when retrieving these values.
Which is the best practice in this case? (by best practice I mean the most inexpensive method, from resource, overhead, execution time, etc point of view)
a. save it as bit and use explicit cast?
(bool)row["boolvalue"] == true
b. save it as tinyint and use ToString()
row["boolvalue"].ToString() == "1"
c. better option I'm not thinking of
P.S. I'm new here, I hope I've posted in the right place and the question is not idiotic. Please let me know if any option is just as good as another.
Have a nice day!
Reply
Answers (
6
)
2D Pong Bounce Angle Questions
how to find out printer status?