1.如何显示行号SQL Server2008
http://jingyan.baidu.com/article/295430f1c48f9e0c7f005040.html
2.解除约束
DELETE FROM Students
报错如下:
要解决这个,就必须先找到和Students 有约束关系的表
SELECT *
FROM sys.foreign_keys
WHERE referenced_object_id=object_id('Students')
ORDER BY 1
查询结果:
ALTER TABLE Scores
DROP CONSTRAINT FK_Scores_Students
然后再删除表就可以了,如果想让表的ID重新从1开始自增长
truncate table Students
最后再把刚刚的外键约束加回来
ALTER TABLE [dbo].[Scores] ADD CONSTRAINT [FK_Scores_Students] FOREIGN KEY([studentId])
REFERENCES [dbo].[Students] ([id])
GO