--删除约束 Status:字段名 alter table Table_1 drop constraint Status; --添加约束 --Status :字段名 t_Pay_Order:表名 默认值 :0 alter table t_Pay_Order add constraint Status default (0) for Status --修改字段名 --Table_1 表名 STATUS:旧字段名 T:新字段名 EXEC sp_rename '[dbo].[Table_1].[STATUS]', ' T', 'COLUMN'
CREATE TABLE #data ( RowNo int IDENTITY (0, 1) NOT NULL, KeyID int not null ) --创建临时表
;WITH cte AS ( SELECT ROW_NUMBER() OVER ( ORDER BY UserID+ @Order) AS ROWNUMBERID , * FROM ( select t0.*,t1.SmallPhoto,t1.NickName,t3.TopicName from t_Soc_UserSpace t0 inner join t_Comm_Users t1 on t0.UserID=t1.UserID inner join t_Soc_Topic t3 on t3.CID=t0.CID WHERE t3.TopicName =@TopicName ) tt) SELECT * FROM cte WHERE ROWNUMBERID BETWEEN (@pageindex - 1) * @PageSize + 1 AND @pageindex * @PageSize SELECT @TotalCount= COUNT(*) from t_Soc_UserSpace t0 inner join t_Comm_Users t1 on t0.UserID=t1.UserID inner join t_Soc_Topic t3 on t3.CID=t0.CID WHERE t3.TopicName =@TopicName