Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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:openrowset / oracle:table/view@dblinkÃû

Ö»ÊÇsqlserver ÌṩµÄÔ¶³ÌÊý¾Ý·ÃÎʺ¯Êý;  ÔÚ±¾µØsqlserver ÖÐÈ¡ÍⲿÊý¾ÝÔ´Êý¾Ýʱºò¿ÉÓÃ;
¶ÔÁ¬½Ó±¾µØ oracle ²Ù×÷Ô¶³Ì oracle ²»ÄÜʹÓÃ; ²âÊÔ: pl/sql ÖÐʹÓÃ:
select * from openrowset(................); ÎÞЧ!!!!!!!!!!!!!!
ÔÚoracle ÖÐÐèÒª·ÃÎÊÔ¶³ÌÊý¾Ý,ÐèÒª½¨Á¢Ò»Á¬½ÓÔ¶³Ìoracle µÄ dblink ;
ÔÙÓÃÈçÏ·½ ......

ʹÓÃSQLServerÄ£°åÀ´Ð´¹æ·¶µÄSQLÓï¾ä

Èç¹ûÄã¾­³£Óöµ½ÏÂÃæµÄÎÊÌ⣬Äã¾ÍÒª¿¼ÂÇʹÓÃSQL ServerµÄÄ£°åÀ´Ð´¹æ·¶µÄSQLÓï¾äÁË£º
SQL³õѧÕß¡£
¾­³£Íü¼Ç³£ÓõÄDML»òÊÇDDL SQL Óï¾ä¡£
ÔÚ¶àÈË¿ª·¢Î¬»¤µÄSQLÖУ¬Ã¿¸öÈ˶¼ÓÐ×Ô¼ºµÄSQLÏ°¹ß£¬Ã»ÓÐÒ»Ì×ͳһµÄ¹æ·¶¡£
ÔÚSQL Server Management StudioÖУ¬ÒѾ­¸ø´ó¼ÒÌṩÁ˺ܶೣÓõÄÏÖ³ÉSQL¹æ·¶Ä£°å¡£
SQL Server Management ......

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;    ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ