I need to fill a bit column only with 0 or 1, I tried the following, which only gave me 1:
convert(bit, 2*rand())
How can I make it work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Passing in any value that’s greater than 0 to this expression will yield a 1 every time. In order to do what you want, you need to round the results yourself:
This will give you a random
0or1bitvalue.