![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a SQL 2005 database that's created by a survey data collection system. Users of this system are fairly non-technical and have little to no conscious control over the datatypes. As a result, the data is mostly stored quite inefficiently as varchars. For example, there is data that could be stored in a column of bits and it's stored as a varchar value of 0 or 1. (Yuck, I know.) |
|
I am building a reporting system using this raw data and have a new table structure designed that is much more efficient (and better for reporting). Does anyone have any suggestions for getting this data into my new structure? Specifically, how would you recommend checking that varchar field and determining it could be stored as a bit? |
#3
| |||
| |||
|
|
SELECT varcharcol, COUNT(*) FROM tbl GROUP BY varcharcol should give you an indication of what really is in that column. Say that you find something like: 0 1234 1 9802 Y 23 N 12 X 1 |
#4
| |||
| |||
|
|
I see the approach you're taking. I should have been more clear in my original post - it's not just bool's that I have issues with - it's every data type. Data that should be stored as an int (or tinyint) is stored as a varchar, data that should be stored as a datetime is stored as a varchar, data that should be stored as a float is stored as a varchar. I'm looking to convert all of that data. Bool data was just an example. |
![]() |
| Thread Tools | |
| Display Modes | |
| |