Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert char col to bool?

Status
Not open for further replies.

TonyScarpelli

Programmer
Jan 23, 2003
361
US
Not too SQL Savy.

I've imported a FoxPro table into SQL Server.

A number of the columns were char 1, with either a 'Y/N' or '1/0' that were used for various flags.

I want to convert these columns to bit or boolean so that they can be used in VB.NET checkboxes.

I've looked at CAST and CONVERT, but am not sure how to convert the columns in the whole table. In FoxPro I would add a new column, set a DO WHILE NOT EOF() loop in a program, and check for the character value, and set it to .T. or .F. in the new column, and finally delete the old column.

How do I do a similar thing in SQL Server?

Thanks.



Tony Scarpelli
Clinical Engineering Dept.
Maine Medical Center
Portland, Maine 04102
 
Use an update for the whole table.
Update table1 set column1 = 0 where column1 = 'y'
 
Thanks, worked like a charm. It was even easier than FoxPro. Once I changed the 'Y/N' to '1/0', I changed the column from char to bit, and it didn't lose any info which I was worried about.

CU


Tony Scarpelli
Clinical Engineering Dept.
Maine Medical Center
Portland, Maine 04102
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top