SQL 脚本

1.oracle列转行

Select Guid as CheckGoodsID,goodsid,code,

                    (Select colordesc from Color where ID = ColorID) as Color,

                    T.Size1,

                    T.Qty

               from SaleListGoodsDetail UNPIVOT(Qty FOR Size1 IN(S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15,S16,S17,S18,S19,S20,S21,S22,S23,S24,S25,S26,S27,S28

      ,S29,S30,S31,S32,S33,S34,S35,S36,S37,S38,S39,S40,S41,S42,S43,S44,S45,S46,S47,S48,S49,S50)) T

2.MCS重算库存

USE [intime]

GO



DECLARE    @return_value int



EXEC    @return_value = [dbo].[p_ReCalcStockByCustomer]

        @DataTable = N'RP_TEMP_J_100_0001_20150711',

        @Customer_ID = N'Z-100-0001',

        @StartDate = N'20150501',

        @EndDate = N'20150501'



SELECT    'Return Value' = @return_value



GO



select * from Customer



select * from RP_TEMP_J_100_0001_20150711

3.MSSqlserver 清除数据库日志

USE [master]

GO

ALTER DATABASE regentdw SET RECOVERY SIMPLE WITH NO_WAIT

GO

ALTER DATABASE regentdw SET RECOVERY SIMPLE --简单模式

GO

USE regentdw

GO

DBCC SHRINKFILE (N'regentdw_log' , 11, TRUNCATEONLY)

/*

--这里的DNName_Log 如果不知道在sys.database_files里是什么名字的话,可以用以下注释的语句进行查询

USE regentdw

GO

SELECT file_id, name FROM sys.database_files;

GO

*/



GO

USE [master]

GO

ALTER DATABASE regentdw SET RECOVERY FULL WITH NO_WAIT

GO

ALTER DATABASE regentdw SET RECOVERY FULL --还原为完全模式

GO

4.重置表的自增字段

delete FROM [ReportFolder]



--重置表的自增字段,保留数据

DBCC CHECKIDENT ([ReportFolder],reseed,0) 



insert into ReportFolder(FolderName) values('我的报表');



select * from [ReportFolder]

 

你可能感兴趣的:(sql)