SQLÑ»·ÓαêµÄʹÓÃ
½ñÌì¸ãµÄ£¬°ïͬʲéѯÊý¾Ý£¬ÏÈд¸ö´¥·¢Æ÷£¬½ØÈ¡http://www.chinaroyalgroup.cn/aspnet_client/system_web/2_0_50727/dispbbs.asp?boardid=1&id=836ÀïµÄÓòÃû
IF EXISTS (SELECT name from sysobjects
WHERE name = 'gs_MySub' AND type = 'P')
DROP PROCEDURE gs_MySub
GO
create proc gs_MySub
@www varchar(100),
@result varchar(100) output,
@end int = 0
as
set @www = REPLACE(@www, 'http://', '') --Ìæ»»µôhttp://
set @end = PATINDEX('%/%', @www) --µÃµ½µÚÒ»´Î³öÏÖ'/'µÄλÖÃ
set @result = SUBSTRING(@www, 0, @end) --½ØÈ¡
GO
SQL²éѯ·ÖÎöÆ÷À
declare cur_domain1 cursor
for
select domain from test1
open cur_domain1
declare @result varchar(100)
declare @domain varchar(100)
Fetch next from cur_domain1
while (@@fetch_status<>-1)
begin fetch next from cur_domain1
INTO:@domain
exec gs_MySub @domain, @result output
print @result
end
close cur_domain1
Ïà¹ØÎĵµ£º
ËäȻ˵ÎÒÃǾ¡Á¿ÔÚд³ÌÐòµÄʱºò¿ØÖƲåÈëµ½Êý¾Ý¿âµÄÊý¾Ý£¬¶ø²»ÒªÓÃÊý¾Ý¿âÈ¥ÅжÏÊý¾ÝµÄ¶Ô´í£¬µ«ÊÇÓÐʱºòΪÁË·½±ã»¹ÊÇÐèÒªÊý¾Ý¿â×ÔÉíµÄÈÝ´íÄÜÁ¦À´°ïÖúÎÒÃǴﵽĿµÄµÄ¡£¾ÙÀý˵Ã÷£º
´´½¨ÈçÏÂÊý¾Ý±í
CREATE TABLE `book` (
`id` int(11) default NULL,
`num` int(11) unsigned default NULL
) ENGINE=InnoDB DE ......
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢É¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ ......
1.×Ö·û´®º¯Êý
³¤¶ÈÓë·ÖÎöÓÃ
datalength(Char_expr) ·µ»Ø×Ö·û´®°üº¬×Ö·ûÊý,µ«²»°üº¬ºóÃæµÄ¿Õ¸ñ
substring(expression,start,length) ²»¶à˵ÁË,È¡×Ó´®
right(char_expr,int_expr) ·µ»Ø×Ö·û´®ÓÒ±ßint_expr¸ö×Ö·û
×Ö·û²Ù×÷Àà
upper(char_expr) תΪ´óд
lower(char_expr) תΪСд
space(int_expr) Éú³Éint_expr¸ ......
ËùνSQL×¢Èëʽ¹¥»÷£¬¾ÍÊǹ¥»÷Õß°ÑSQLÃüÁî²åÈëµ½Web±íµ¥µÄÊäÈëÓò»òÒ³ÃæÇëÇóµÄ²éѯ×Ö·û´®£¬ÆÛÆ·þÎñÆ÷Ö´ÐжñÒâµÄSQLÃüÁî¡£ÔÚijЩ±íµ¥ÖУ¬Óû§ÊäÈëµÄÄÚÈÝÖ±½ÓÓÃÀ´¹¹Ôì(»òÕßÓ°Ïì)¶¯Ì¬SQLÃüÁ»ò×÷Ϊ´æ´¢¹ý³ÌµÄÊäÈë²ÎÊý£¬ÕâÀà±íµ¥ÌرðÈÝÒ×Êܵ½SQL×¢Èëʽ¹¥»÷¡£³£¼ûµÄSQL×¢Èëʽ¹¥»÷¹ý³ÌÀàÈ磺
¡¡¡¡¢Å ij¸öASP.NET WebÓ¦ÓÃÓÐÒ»¸ö ......
--sql server 2005
-- 1. ±í½á¹¹ÐÅÏ¢²éѯ
-- ========================================================================
-- ±í½á¹¹ÐÅÏ¢²éѯ
-- ×Þ½¨ 2005.08(ÒýÓÃÇë±£Áô´ËÐÅÏ¢)
-- ========================================================================
SELECT
TableName=CASE WHEN ......