.Pivot的用法体会: 语句范例: select PN,[2006/5/30] as [20060530],[2006/6/2] as [20060602] from consumptiondata a Pivot (sum(a.M_qty) FOR a.M_date in ([2006/5/30],[2006/6/2])) as PVT order by PN Table结构 Consumptiondata (PN,M_Date,M_qty) order by PN可要可不要,并不重
原文:SQL Server 中 EXEC 与 SP_EXECUTESQL 的区别 MSSQL为我们提供了两种动态执行SQL语句的命令,分别是 EXEC 和 SP_EXECUTESQL ,我们先来看一下两种方式的用法. 先建立一个表,并添加一些数据来进行演示: CREATE TABLE t_student( Id INT NOT NULL, Name NVARCHAR (10) NULL, Age TINYINT NULL, School NVARCHAR(20) NULL, Class NVAR