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

ÓÃ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


Ïà¹ØÎĵµ£º

Çå³ýSQL SERVER Êý¾Ý¿âÈÕÖ¾

  1.Çå¿ÕÈÕÖ¾  
  DUMP     TRANSACTION     ¿âÃû     WITH     NO_LOG          
   
  2.½Ø¶ÏÊÂÎñÈÕÖ¾£º  
  BACKUP   LOG   Êý¾Ý¿âÃû   WITH   NO_LOG  
    ......

Linq to sqlÔöɾ¸Ä²é

private void button2_Click(object sender, EventArgs e)//Ôö
{
try
{
Customers ct = new Customers();
ct.CustomerID = "test";
ct.CompanyName = "test";
NorthwindDataContext nc = new NorthwindDataContex ......

×¢Èë³£ÓÃSQLÓï¾ä


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')) //Å ......

SQL SERVER Óαê

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 ......

SQL code¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨

SQL code¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨
 1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ
eg: Select * from tableName
Exec('select * from tableName')
Exec sp_executesql N 'select * from tableName'
 -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
eg: declare @fname varchar(20) ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ