0

I have a column where I need to update it's value by random numbers between 1 and 3150 (just being specific)

Can I do this with a simple TSQL statement?

1 Answer 1

2

Use RAND(), re-seeding the function on each call.

UPDATE MyTable
SET MyColumn = 1 + FLOOR(3150 * RAND(CONVERT(varbinary, NEWID())))
WHERE ...
Sign up to request clarification or add additional context in comments.

1 Comment

CHECKSUM(NEWID()) could be used too to seed RAND

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.