回覆列表
-
1 # 使用者1220686403821
-
2 # 使用者2458114238191884
declare @sql varchar(8000)
SELECT @sql="drop table " + name
FROM sysobjects
WHERE (type = "U")
ORDER BY "drop table " + name
exec(@sql)
declare @sql varchar(8000)
SELECT @sql="truncate table " + name
FROM sysobjects
WHERE (type = "U")
ORDER BY "truncate table " + name
exec(@sql)
慎用!
用程式碼
altertable表名addconstraintpk_表名primarykey(欄位)--新增主鍵約束
altertable表名addconstraint約束名unique(列名)--向已有表新增唯一約束
createtable資料表名addconstraint約束名default預設值for欄位--預設值約束