Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLSERVER ·ÖÒ³´æ´¢¹ý³Ì(2 ÔÚSQL2005ÏÂʹÓÃ)

֮ǰÓÐÒ»¸öSQLServerµÄ·ÖÒ³´æ´¢¹ý³Ì µ«ÊÇÐÔÄܲ»ÊÇÊ®·ÖÀíÏë
ÓÖÕÒÁËÒ»¸ö 
--SQL2005·ÖÒ³´æ´¢¹ý³Ì
/**
if  exists(select * from sysobjects where name='fenye')
drop proc fenye
**/
CREATE procedure fenye
  @tableName nvarchar(200) ,
  @pageSize int,
  @curPage int ,
  @orderBy nvarchar(200) ,
  @field nvarchar(200) = '*' ,
  @condition nvarchar(200)
AS
  SET NOCOUNT ON
  DECLARE
     @STMT nvarchar(max),        -- SQL to execute
     @recct int                  -- total # of records (for GridView paging interface)
  IF LTRIM(RTRIM(@condition)) = '' SET @condition = '1 = 1'
  IF @pageSize IS NULL BEGIN
    SET @STMT =  'SELECT   ' + @field + 'from ' + @tableName +'WHERE    ' + @condition + 'ORDER BY   ' + @orderBy
    EXEC (@STMT)                 -- return requested records
  END ELSE BEGIN
    SET @STMT =  'SELECT   @recct = COUNT(*) from     ' + @tableName + '    WHERE    ' + @condition
   -- EXEC sp_executeSQL @STMT, @params = N'@recct INT OUTPUT', @recct = @recct OUTPUT
    --SELECT @recct AS recct       -- return the total # of records
    DECLARE
      @lbound int,
      @ubound int
    SET @curPage = ABS(@curPage)
    SET @pageSize = ABS(@pageSize)
    IF @curPage < 1 SET @curPage = 1
    IF @pageSize < 1 SET @pageSize = 1
    SET @lbound = ((@curPage - 1) * @pageSize)
    SE


Ïà¹ØÎĵµ£º

SQLSERVER SQLÐÔÄÜÓÅ»¯

1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á ......

Sqlserver È¡ºº×ֵĵÚÒ»¸ö×Öĸ£¬·½±ãÄ£ºý²éѯ

 create function comm_getpy
(
    @str nvarchar(4000)
)
returns nvarchar(4000)
as
begin
declare @word nchar(1),@PY nvarchar(4000)
set @PY=''
while len(@str)>0
begin
    set @word=left(@str,1)
    --Èç¹û·Çºº×Ö×Ö·û£¬·µ»ØÔ­×Ö·û
& ......

java µ÷ÓÃͨÓô洢¹ý³Ì£¨Sqlserver£©


package com.wfy.system.dao;   
  
import java.sql.CallableStatement;   
import java.sql.Connection;   
import java.sql.ResultSet;   
import java.sql.SQLException;   
import java.sql.Types;    ......

sqlserver×Ö·û´®²ð·Ö(split)·½·¨»ã×Ü

sqlserver×Ö·û´®²ð·Ö(split)·½·¨»ã×Ü
--·½·¨0£º¶¯Ì¬SQL·¨
declare @s varchar(100),@sql varchar(1000)
set @s='1,2,3,4,5,6,7,8,9,10'
set @sql='select col='''+ replace(@s,',',''' union all select ''')+''''
PRINT @sql
exec (@sql)
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ