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

sql²éÕÒij¸ö×Ö·û´®µÚN´Î³öÏÖµÄλÖõĺ¯Êý(תÌû)

if exists(select 1 from sysobjects where name='char_index')
drop function char_index
create function char_index(@string varchar(8000),@char varchar(10),@index smallint)
--@string:´ý²éÕÒ×Ö·û´®£¬@index:²éÕÒλÖÃ
returns smallint
as
begin
  declare
  @i tinyint,--µ±Ç°ÕÒµ½µÚ@i¸ö
  @position tinyint--ËùÔÚλÖÃ
  set @position=@index;
  set @i=0;
  while charindex(@char,@string,@position)>0
  begin
    set @position=charindex(@char,@string,@position)+1;
    set @i=@i+1;
    if @i=@index
    begin
     return @position-1;
    end
  end
  return 0;--0±íʾδÕÒµ½
end
select dbo.char_index('sdf_dsf_dfgdg_ertr_erte','f_',2)
--ÈçºÎ²éÕÒij¸ö×Ö·û´®µÚN´Î³öÏÖµÄλÖÃ,
--±ÈÈç:×Ö·û´®"sdf_dsf_dfgdg_ertr_erte",Òª²éÕÒ"f_"µÚ¶þ´Î³öÏÖµÄλÖÃ
if object_id('f_findstr') is not null
drop function f_findstr
go
create function f_findstr(@s varchar(8000),@find varchar(10),@index int)
returns int
as
begin
declare @startindex int
set @startindex=0
while @index>0
begin
if charindex(@find,@s,@startindex)>0
set @startindex=charindex(@find,@s,@startindex+1)
set @index=@index-1
end
return @startindex
end
go
select dbo.f_findstr('sdf_dsf_dfgdg_ertr_erte','f_',2)
use test
go
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[F_Str]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[F_Str]
GO
CREATE FUNCTION dbo.F_Str(
@s varchar(8000), 
@pos int,         
@split varchar(10)
)RETURNS int
AS
BEGIN
    IF @s IS NULL RETURN(NULL)
    DECLARE @splitlen int,@i int
    SELECT @splitlen=LEN(@split+'a')-2,@i=0
    WHILE @pos>1 AND CHARINDEX(@split,@s+@split)>0
        SELECT @pos=@pos-1,@i=@i+CHARINDEX(@split,@s+@split)+@splitlen,
&nb


Ïà¹ØÎĵµ£º

¾­µäSQLÓï¾ä´óÈ«

ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
......

SQL²éѯÓï¾äʹÓÃ

Ò»¡¢¼òµ¥²éѯ
¡¡¡¡ ¼òµ¥µÄTransact-SQL²éѯֻ°üÀ¨Ñ¡ÔñÁÐ±í¡¢from×Ó¾äºÍWHERE×Ӿ䡣
ËüÃÇ·Ö±ð˵Ã÷Ëù²éѯÁС¢²éѯµÄ
±í»òÊÓͼ¡¢ÒÔ¼°ËÑË÷Ìõ¼þµÈ¡£
ÀýÈ磬ÏÂÃæµÄÓï¾ä²éѯtesttable±íÖÐÐÕÃûΪ“ÕÅÈý”µÄnickname×ֶκÍemail×ֶΡ£
SELECT nickname,email
from testtable WHERE name='ÕÅÈý'
(Ò»)Ñ¡ÔñÁбí
¡ ......

C#µ÷ÓÃSQL´æ´¢¹ý³ÌÒÔ¼°·µ»ØÖµºÍ²ÎÊýµÄ»ñÈ¡

QZone Editor
.dump{}

//TODO ÓòÃû
if (location.hash) {
document.domain=location.hash.substr(1);
}

//parent.qZEditor.callback();
function init(){
//»ñÈ¡±à¼­Æ÷Ãæ°åID
var pid = frameElement.panelID;

//»ñÈ¡±à¼­Æ÷Ãæ°å¶ÔÏó ......

sqlÊÂÎñ´¦Àí


 
BEGIN TRANSACTION--¿ªÊ¼ÊÂÎñ
DECLARE @errorSun INT --¶¨Òå´íÎó¼ÆÊýÆ÷
SET @errorSun=0 --û´íΪ0
UPDATE a SET id=232 WHERE a=1 --ÊÂÎñ²Ù×÷SQLÓï¾ä
SET @errorSun=@errorSun+@@ERROR --ÀÛ¼ÆÊÇ·ñÓдí
UPDATE aa SET id=2 WHERE a=1 --ÊÂÎñ²Ù×÷SQLÓï¾ä
SET @errorSun=@errorSun+@@ERROR --ÀÛ¼ÆÊÇ·ñÓдí
I ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ