0

How can we insert random values into a newly created column in a table in SQL Server?

I tried this:

alter table [dbo].[employee] add phoneno int

select * from [dbo].[employee]
update employee set phoneno=(ROUND((RAND(),0)) where phoneno NULL
2

1 Answer 1

0

Rather than two steps you could define the initial values using a DEFAULT constraint on the new column.

Not the answer you're looking for? Browse other questions tagged or ask your own question.