【发布时间】:2014-10-15 07:54:15
【问题描述】:
我了解如何将新列和默认 int 添加到表中。
ALTER TABLE Cards
ADD Amex int NOT NULL DEFAULT(1) // how can I add a random number (between 1, to 10) or random date (jan to feb etc)?
GO
如何将新列添加到表中,并用 1 到 10 之间的随机整数或随机日期填充?
编辑 - 从下面回答:
Create table cards (
Amex int NOT NULL DEFAULT (cast(right(cast(checksum(newid()) as varchar(255)), 1) as int) + 1)
);
【问题讨论】:
-
对于随机日期,请查看此帖子 - stackoverflow.com/questions/794637/…
标签: sql sql-server database-administration