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

SqlServer´æ´¢¹ý³Ì·ÖÒ³

--TOP n ʵÏÖµÄͨÓ÷ÖÒ³´æ´¢¹ý³Ì(ת×Ô×Þ½¨)
CREATE PROC sp_PageView
@tbname sysname, --Òª·ÖÒ³ÏÔʾµÄ±íÃû
@FieldKey nvarchar(1000), --ÓÃÓÚ¶¨Î»¼Ç¼µÄÖ÷¼ü(Ωһ¼ü)×Ö¶Î,¿ÉÒÔÊǶººÅ·Ö¸ôµÄ¶à¸ö×Ö¶Î
@PageCurrent int=1, --ÒªÏÔʾµÄÒ³Âë
@PageSize int=10, --ÿҳµÄ´óС(¼Ç¼Êý)
@FieldShow nvarchar(1000)='', --ÒÔ¶ººÅ·Ö¸ôµÄÒªÏÔʾµÄ×Ö¶ÎÁбí,Èç¹û²»Ö¸¶¨,ÔòÏÔʾËùÓÐ×Ö¶Î
@FieldOrder nvarchar(1000)='', --ÒÔ¶ººÅ·Ö¸ôµÄÅÅÐò×Ö¶ÎÁбí,¿ÉÒÔÖ¸¶¨ÔÚ×ֶκóÃæÖ¸¶¨DESC/ASC
ÓÃÓÚÖ¸¶¨ÅÅÐò˳Ðò
@Where nvarchar(1000)='', --²éѯÌõ¼þ
@PageCount int OUTPUT --×ÜÒ³Êý
AS
SET NOCOUNT ON
--¼ì²é¶ÔÏóÊÇ·ñÓÐЧ
IF OBJECT_ID(@tbname) IS NULL
BEGIN
RAISERROR(N'¶ÔÏó"%s"²»´æÔÚ',1,16,@tbname)
RETURN
END
IF OBJECTPROPERTY(OBJECT_ID(@tbname),N'IsTable')=0
AND OBJECTPROPERTY(OBJECT_ID(@tbname),N'IsView')=0
AND OBJECTPROPERTY(OBJECT_ID(@tbname),N'IsTableFunction')=0
BEGIN
RAISERROR(N'"%s"²»ÊÇ±í¡¢ÊÓͼ»òÕß±íÖµº¯Êý',1,16,@tbname)
RETURN
END
--·ÖÒ³×ֶμì²é
IF ISNULL(@FieldKey,N'')=''
BEGIN
RAISERROR(N'·ÖÒ³´¦ÀíÐèÒªÖ÷¼ü£¨»òÕßΩһ¼ü£©',1,16)
RETURN
END
--ÆäËû²ÎÊý¼ì²é¼°¹æ·¶
IF ISNULL(@PageCurrent,0)<1 SET @PageCurrent=1
IF ISNULL(@PageSize,0)<1 SET @PageSize=10
IF ISNULL(@FieldShow,N'')=N'' SET @FieldShow=N'*'
IF ISNULL(@FieldOrder,N'')=N''
SET @FieldOrder=N''
ELSE
SET @FieldOrder=N'ORDER BY '+LTRIM(@FieldOrder)
IF ISNULL(@Where,N'')=N''
SET @Where=N''
ELSE
SET @Where=N'WHERE ('+@Where+N')'
--Èç¹û@PageCountΪNULLÖµ,Ôò¼ÆËã×ÜÒ³Êý(ÕâÑùÉè¼Æ¿ÉÒÔÖ»ÔÚµÚÒ»´Î¼ÆËã×ÜÒ³Êý,ÒÔºóµ÷ÓÃʱ,°Ñ×ÜÒ³Êý´«»Ø¸ø´æ´¢¹ý³Ì,±ÜÃâÔٴμÆËã×ÜÒ³Êý,¶ÔÓÚ²»Ïë¼ÆËã×ÜÒ³ÊýµÄ´¦Àí¶øÑÔ,¿ÉÒÔ¸ø@PageCount¸³Öµ)
IF @PageCount IS NULL
BEGIN
DECLARE @sql nvarchar(4000)
SET @sql=N'SELECT @PageCount=COUNT(*)'
+N' from '+@tbname
+N' '+@Where
EXEC sp_executesql @sql,N'@PageCount int OUTPUT',@PageCount OUTPUT
SET @PageCo


Ïà¹ØÎĵµ£º

Oracle´æ´¢¹ý³Ìת³ÉSqlserver´æ´¢¹ý³Ì

Oracle´æ´¢¹ý³Ìת³ÉSqlserver´æ´¢¹ý³Ì
1.ÈÕÆÚת»»
Oracle£º TO_NUMBER(TO_CHAR(SYSDATE, 'YYYYMMDD'))
SqlServer£ºCAST(CONVERT(CHAR(8),GETDATE(), 112) AS INT)
    ×¢£ºÆäÖБYYYYMMDD’¸ñʽ   ¶ÔÓ¦112
2.ROWIDת»»
Oracle£º ROWID
SqlServer: PRIMARY KEY(±íÖ÷¼ü)
3.ROWNUM ......

PHP²éѯÏÔʾSqlServerÖеÄÖÐÎÄ

ÒòΪ¹¤×÷ÐèÒª£¬Êý¾Ý¿âʹÓõÄMS SQL Server2005£¬¶øÄ¬ÈϵÄÅÅÐò¹æÔòÊÇSQL_Latin1_General_CP1_CI_AS¡£´´½¨ÁËÒ»¸ö±í£¬ÒòΪÐèÒª´æ´¢ÖÐÎÄÐÅÏ¢£¬Address×ֶεÄÀàÐÍÊÇnvarchar(255)¡£
´ËʱʹÓÃphpÀ´Á¬½Ósql server£¬Ò³ÃæµÄ±àÂëºÍÎļþµÄ±àÂë¶¼ÊÇUTF-8£¬²éѯ´ËAddress×ֶΣ¬ÏÔʾÔÚÒ³ÃæÉÏÊÇ???Ö®ÀàµÄ¡£Ôõô½â¾ö£¿
ʹÓÃ
iconv('iso- ......

sqlserver×Ö·û´®ºÏ²¢(merge)·½·¨»ã×Ü

ÎÞÂÛÊÇÔÚsql 2000£¬»¹ÊÇÔÚ sql 2005 ÖÐ,¶¼Ã»ÓÐÌṩ×Ö·û´®µÄ¾ÛºÏº¯Êý£¬ËùÒÔ£¬µ±ÎÒÃÇÔÚ´¦ÀíÏÂÁÐÒªÇóʱ£¬»á±È½ÏÂé·³£ºÓбítb, ÈçÏ£ºid value----- ------1 aa1 bb2 aaa2 bbb2 cccÐèÒªµÃµ½½á¹û£ºid values------ -----------1 aa,bb2 aaa,bbb,ccc¼´£¬ group by id, Çó value µÄºÍ£¨×Ö·û´®Ïà¼Ó£© 1. ¾ÉµÄ½â¾ö·½·¨-- 1. ´´½¨´¦À ......

SqlServer²åÈëÂýµÄÎÊÌâ½â¾ö

Õâ¸öÊÇÎÒ¼ÓÈëµÄQQȺÀïÃæÒ»¸öÍøÓÑÎʵÄÎÊÌâ¡£Ëû˵һ¸ö±í×öÒ»¸öINSERT¶¼»á³¬Ê±¡£ÕýÀ§»óÄØ£¬ÏòȺÀïÃæµÄÈËÇóÖú¡£ÎҸպöÔÕâ·½ÃæÖªµÀµã£¬¾Í»Ø´ðÁË˵ҪÓÅ»¯¾Û¼¯Ë÷Òý¡£Ëû²»Ã÷°×¾ßÌå¸ÃÔõô×ö£¬ËƺõÒ²²»ÖªµÀʲôÊǾۼ¯Ë÷Òý¡£ÎÒ¶ÔËû˵Äã¿ÉÒÔ¿´¿´Äã²åÈë¼Ç¼ʱµÄ´ÅÅÌIOÊÇ·ñ±È½Ï¶à£¬Ëû˵ËûµÄ´ÅÅÌÒѾ­»»³ÉÁËRAID£¬²»ºÃ²é¿´´ÅÅÌIO¡£OK, ÎÒ¼Ì ......

C#Á¬½ÓsqlserverÊý¾Ý¿â


       µ±ÔÚC#ÓïÑÔÖУ¬Á¬½ÓsqlÊý¾Ý¿âµÄʱºò£¬³£Óõ½sqlconnection½¨Á¢ÓëÊý¾Ý¿âµÄÁ¬½Ó¡£ Óï·¨ÈçÏ£º
       String sqlcon = "***";//ÕâÀïÊÇÒ»¸ö×Ö·û´®£¬¾ßÌå¸úÊý¾Ý¿âµÄÑéÖ¤·½Ê½Óйء£
//sql server Éí·ÝÑéÖ¤ Á¬½Ó×Ö·û´®
private string ConnstrSqlServer = "server=·þÎñÆ÷Ãû³ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ