Skip to content
Advertisement

Update table and add new column with check for all rows for UserName numbers | SQL Server

I need add this script

But after the update, I need to check all old rows in MyTable – all UserName (it is column in this table) if UserName has only numbers? If yes – set true for this row MyNewColumnCheckUserName.

Advertisement

Answer

You can use:

However, I would recommend just adding this as a computed column:

There is no reason that I know of to prefer a bit instead of a number for a computed column. But if you really want to incur the overhead of a bit, you can convert the value:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement