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
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityHow 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
Rather than two steps you could define the initial values using a DEFAULT constraint on the new column.