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


Ïà¹ØÎĵµ£º

sqlserver bcpÃüÁ¿ìËÙ´¦Àí´óÊý¾Ý

bcpÃüÁîÊÇSQL ServerÌṩµÄÒ»¸ö¿ì½ÝµÄÊý¾Ýµ¼Èëµ¼³ö¹¤¾ß¡£Ê¹ÓÃËü²»ÐèÒªÆô¶¯ÈκÎͼÐιÜÀí¹¤¾ß¾ÍÄÜÒÔ¸ßЧµÄ·½Ê½µ¼Èëµ¼³öÊý¾Ý¡£bcpÊÇSQL ServerÖиºÔðµ¼Èëµ¼³öÊý¾ÝµÄÒ»¸öÃüÁîÐй¤¾ß£¬ËüÊÇ»ùÓÚDB-LibraryµÄ£¬²¢ÇÒÄÜÒÔ²¢Ðеķ½Ê½¸ßЧµØµ¼Èëµ¼³ö´óÅúÁ¿µÄÊý¾Ý¡£bcp¿ÉÒÔ½«Êý¾Ý¿âµÄ±í»òÊÓͼֱ½Óµ¼³ö£¬Ò²ÄÜͨ¹ýSELECT fromÓï¾ä¶Ô±í»òÊÓ ......

¹ØÓÚupdateÓï¾äÔÚsqlserverºÍAccessÖеĶԱÈ

sqlserver£ºupdate Table_A set Table_A.col1 = (select Table_B.col1 from Table_B where Table_A.col2 = Table_B.col2)
Access: UPDATE Table_ A, Table_B SET Table_ A.×Ö¶Î2 = Table_ B.×Ö¶Î2
WHERE Table_ A.񅧏=Table_ A.񅧏;
×Ô¼º¼ÇÏ£¬ÌáÐÑ×Ô¼º ......

C#¹ØÓÚsqlserverÖжÁÈ¡imageÀàÐÍ

½ñÌìÔÚÍøÉÏÕÒÁËÐí¾Ã¹ØÓÚsqlserverÖд洢imageÀàÐͺͶÁÈ¡imageµÄ·½·¨£¬¿ÉÊǶ¼ÊÇÄÇôһµã£¬¹ÊÔÚ´ËÂÞÁÐһϣ¬Ï£Íû¿ÉÒÔ°ïÖú´ó¼Ò¡£
Ê×ÏÈÊǹØÓÚdataGridViewµÄ°ó¶¨¡£´úÂë¼ûÏÂ
private void button_show_Click(object sender, EventArgs e)
{
string sqlText = "server=localhost;initial catalog=Test; ......

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ÖÐÓÃconvertº¯Êýת»»ÈÕÆÚ¸ñʽ

SQLserverÖÐÓÃconvertº¯Êýת»»ÈÕÆÚ¸ñʽ
2008-01-23 15:47
SQLserverÖÐÓÃconvertº¯Êýת»»ÈÕÆÚ¸ñʽ2008-01-15 15:51SQLserverÖÐÓÃconvertº¯Êýת»»ÈÕÆÚ¸ñʽ
SQL ServerÖÐÎÄ°æµÄĬÈϵÄÈÕÆÚ×Ö¶Îdatetime¸ñʽÊÇyyyy-mm-dd Thh:mm:ss.mmm
ÀýÈç:
select getdate()
2004-09-12 11:06:08.177
ÕûÀíÁËÒ»ÏÂSQL ServerÀïÃæ¿ÉÄÜ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ