Im writing a database for some kind of university and there is a table named
Contact_Assign Its parameters are:
Is_Instructor UD_BOOLEAN NOT NULL,
Is_TeacherAssistant UD_BOOLEAN NOT NULL,
Is_Student UD_BOOLEAN NOT NULL,
Registration_ID UD_ID NOT NULL,
Contact_ID UD_ID NOT NULL,
now I want to insert dummy data in this table but I have no idea how can I do this for the boolean parameters.
PS. UD_BOOLEAN is
CREATE TYPE UD_BOOLEAN FROM BIT
any idea how?
You can use
CRYPT_GEN_RANDOM(1) % 2
The advantages over RAND
are that it is stronger cryptographically (you may not care) and that if inserting multiple rows it is re-evaluated for each row.
DECLARE @T TABLE(
B1 BIT,
B2 BIT);
INSERT INTO @T
SELECT TOP 10 CRYPT_GEN_RANDOM(1)%2,
CAST(ROUND(RAND(), 0) AS BIT)
FROM master..spt_values
SELECT *
FROM @T
would give the same value in all rows for the second column
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With