Wednesday 15 July 2015

SQL Server add new column to table and filled random integer in range -



SQL Server add new column to table and filled random integer in range -

i understand how add together new column , default int table.

alter table cards add together amex int not null default(1) // how can add together random number (between 1, 10) or random date (jan feb etc)? go

how add together new column table, , fill random integer between 1 , 10, or random date?

edit - reply below:

create table cards ( amex int not null default (cast(right(cast(checksum(newid()) varchar(255)), 1) int) + 1) );

you can update. number 1 10, next should work:

update cards set amex = cast(right(cast(checksum(newid()) varchar(255)), 1) int) + 1

edit:

here illustration of beingness used in create table statement.

sql sql-server database-administration

No comments:

Post a Comment