ÓÃSQLÉú³ÉÁ÷Ë®ºÅ
ÓÃSQLÉú³ÉÁ÷Ë®ºÅ
ת£ºÎ¤½ÌÎ ·¢±íÓÚ2010Äê02ÔÂ03ÈÕ 09:38 ÔĶÁ(4) ÆÀÂÛ(0)
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fn_FillNumberWithZero]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fn_FillNumberWithZero]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fn_FormatDate]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fn_FormatDate]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fn_GetNewFlowNumber]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fn_GetNewFlowNumber]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fn_GetNowDate]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fn_GetNowDate]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
/*
Éú³ÉÁ÷Ë®ºÅºóÃ漸λÊý×Ö×Ö·ûµÄÏà¹Øº¯Êý
²»×ãλÊýÔÚ×ó±ßÓÃ0Ìî³ä
*/
CREATE FUNCTION dbo.fn_FillNumberWithZero
(
--Ìî³äµÄÊý×Ö
@num int,
--×ÜλÊý
@len int
)
RETURNS varchar(50) AS
BEGIN
--Èç¹û´«ÈëµÄÁ÷Ë®ºÅ´óÓÚ×ܵij¤¶È£¬ÄÇôֱ½Ó·µ»ØÁ÷Ë®ºÅ×Ö·û´®¸ñʽ
if(len(Convert(varchar(50),@num))>@len)
return Convert(varchar(50),@num)
ELSE
BEGIN
--ÐèÒªÌî³ä0µÄλÊý
declare @NeedFillLen int
set @NeedFillLen=@Len-len(Convert(varchar(50),@num))
--»ñÈ¡ÐèÒªÌî³äµÄ0µÄ×Ö·û´®
declare @i int
set @i=0
declare @temp varchar(50)
set @temp=N''
while @i<@NeedFillLen
BEGIN
SET @temp=@temp+'0'
SET @i=@i+1
END
--·µ»Ø×éºóµÄ×Ö·û´®
return @temp+Convert(varchar(50),@num)
END
return ''
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
Ïà¹ØÎĵµ£º
1¡¢ÔÚÁíһ̨»úÆ÷ÉϽ¨Á¢¶ÀÁ¢µÄÊý¾Ý¿â·þÎñÆ÷£¬×÷ΪÁ´½ÓÄ¿±ê
2¡¢±¾µØÊý¾Ý¿â·þÎñÆ÷ÉÏÌí¼Ó“Á´½Ó·þÎñÆ÷”£º
Ãû×Ö£ºËæ±ãÈ¡Ò»¸öÃû×Ö
·þÎñÆ÷ÀàÐÍ£ºÑ¡ÔñÊý¾ÝÔ´£ºMicrosoft OLE DB Provider for SQL Server
Êý¾ÝÔ´£ºÐ´±ðÃû£¨ÔÚ¿Í»§¶ËÍøÂçʵÓù¤¾ßÖÐÉèÖã©
Ñ¡ÖÐRPCºÍRPCÊä³ö ......
and exists (select * from sysobjects) //ÅжÏÊÇ·ñÊÇMSSQL
and exists(select * from tableName) //ÅжÏij±íÊÇ·ñ´æÔÚ..tableNameΪ±íÃû
and 1=(select @@VERSION) //MSSQL°æ±¾
And 1=(select db_name()) //µ±Ç°Êý¾Ý¿âÃû
and 1=(select @@servername) //±¾µØ·þÎñÃû
and 1=(select IS_SRVROLEMEMBER('sysadmin')) //Å ......
PL/SQL ²»¾ß±¸ÊäÈëÊä³öµÄÄÜÁ¦
µ«ÊÇ¿ÉÒÔÒÀ¿¿»·¾³À´Ö´ÐÐÊýÖµµÄÊäÈëÊä³ö¸øPL/SQL ¿é
SQLPLUS »·¾³ÓÃsubstitution variables ºÍ host(bind) variable À´´«ÈëÊýÖµ¸øPL/SQL¿é
substitution variable: such as a preceding ampersand &a
host(bind) variable : such as a preceding colon :x
Ìæ ......
SqlServer 2000 ÓαêÓ÷¨Ð¡Àý ·µ¯ÑºÎ²É£Cannon(¿¨Ù¯) »
--------------------------------------------------------------------------------
DECLARE CURSOR (T-SQL)´´½¨Óαê
September 14th, 2006 by OoperMan (1 votes, average: 5 out of 5) Loading ...
SQL Server 2005 Áª»ú´ÔÊé
DECLARE CURSOR ......
×÷Õߣº²»Ïê ³ö´¦£ºÍøÂçתÔØ 2009/11/18 10:35:22 ÔĶÁ 109 ´Î
¡¡¡¡¼¼Êõˮƽ×ÜÄÜÔÚ³¶Æ¤ºÍ´µÃ«Çó´ÃÖеõ½Ìá¸ß¡£Èç¹û´ÓÀ´²»“Çó´Ã”£¬¿ÉÄܾͲ»»áÖªµÀif(str != "")²»Èçif(str != string.Empty)¸ßЧ¡¢ÅúÁ¿²åÈëºÍɾ³ýµÄsqlÓï¾äÊÇÒªÄÇÑùд²ÅÖ´ÐÐ×î¿ì¡¢½Ó¿ÚºÍ³éÏóÀàµÄÇø±ð²»½öÊÇÓïÑÔ²ãÃæ¡¢ ......