赞
踩
USE [数据库名称]
GO
/****** Object: StoredProcedure [dbo].[存储过程名称] Script Date: 2024/2/19 9:47:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[存储过程名称:Pro_XXXXXXX]
@Code VARCHAR(32),
@UserId INT,
@StartDate DATETIME = NULL,
@EndDate DATETIME = NULL,
@PageIndex INT,
@PageSize INT
AS
BEGIN
--SQL语句
示例:
单独查询语句
SELECT XXX FROM TTT WHERE FIELD1=@Code AND....
单独修改语句
UPDATE TTT SET FIELD1=@StartDate,FIELD2=@EndDate WHERE FIELD3=@Code....
复合SQL语句(按照自己的顺序往下写就好)
--------查询数据到临时表--------
SELECT
*
INTO #tempTable
FROM 表1(NOLOCK) A
LEFT JOIN 表2(NOLOCK) B ON A.cFormCode = B.cProductCode
WHERE 1=1--------读取数据--------
SELECT * FROM #tempTable
WHERE RowNum BETWEEN (@PageIndex - 1) * @PageSize + 1 AND @PageIndex * @PageSize
ORDER BY RowNum ASC;--------删除临时表--------
DROP TABLE #tempTable;
END
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。