sql约束问题,求高手解答 学号为11位,如果不足11位或多于11位,则拒绝输入 Sno nchar(10)怎么用约束实现 create rule [dbo].[f1] as @aa like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
GO
------解决方案--------------------
SQL code
ALTER TABLE [ta] WITH CHECK ADD CONSTRAINT [CK_ta_1] CHECK (([Sno] like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'))
GO
ALTER TABLE [ta] WITH CHECK ADD CONSTRAINT [CK_ta] CHECK ((len([Sno ])<=(11)))
GO