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

SQLServerÖеÄScanfºÍPrintf ÊÕ²Ø

SQLServerÖÐÓÐÁ½¸öÀ©Õ¹´æ´¢¹ý³ÌʵÏÖScanfºÍPrintf¹¦ÄÜ£¬Ç¡µ±µÄʹÓÃËüÃÇ¿ÉÒÔÔÚÌáÈ¡ºÍÆ´½Ó×Ö·û´®Ê±´ó·ù¶È¼ò»¯SQL´úÂë¡£
1¡¢xp_sscanf£¬ÓÃËü¿ÉÒÔ·Ö½â¸ñʽÏà¶Ô¹Ì¶¨µÄ×Ö·û´®£¬Õâ¶ÔÓÚÑá¾ëʹÓÃÒ»¶ÑsubstringºÍcharindexµÄÅóÓÑÀ´Ëµ²»´í¡£±ÈÈçÇ°¼¸ÌìµÄÒ»¸öÌû×ÓÖÐÌá³öµÄÈçºÎ·Ö½âipµØÖ·£¬Ïà¶Ô¼òÁ·ÇÒͨÓõĴúÂëÓ¦¸ÃÊÇÏÂÃæÕâÑù
--------------------------------------------------------------------------------
if (object_id ('f_getip' ) is not null )
drop function f_getip
go
create function dbo . f_getip (@ ip varchar (100 ))
returns @ t table (a int , b int , c int , d int )
as
begin
    set @ ip = replace (@ ip , '.' , ' ' )
    declare
    @ s1 varchar (3 ) , @ s2 varchar (3 ),
    @ s3 varchar (3 ) , @ s4 varchar (3 )
    exec xp_sscanf @ ip , '%s %s %s %s' , @ s1 output , @ s2 output , @ s3 output , @ s4 output
    insert into @ t select @ s1 , @ s2 , @ s3 , @ s4
    return
end
go
select * from dbo . f_getip ('192.168.0.1' )
go
/*
a           b           c           d
----------- ----------- ----------- -----------
192         168         0           1
*/
2¡¢xp_sprintf£¬ÓÃËü¿ÉÒÔÆ´½Ó³öÒ»¸ö×Ö·û´®¶ø²»Óõ£ÐĹý¶àµÄ¼ÓºÅºÜÒýºÅÄÑÒÔ¿ØÖÆ£¬±ÈÈçÒ»¸ö¶¯Ì¬Ö´ÐÐsqlÓï¾äµÄ´æ´¢¹ý³Ì
if (object_id ('p_select' ) is not null )
drop proc p_select
go
create proc p_select (@ tb varchar (100 ), @ cols varchar (100 ), @ wherecol varchar (100 ), @ value varchar (100 ))
as
begin
    declare @ s varchar (8000 )
    exec xp_sprintf @ s output , 'select %s from %s where %s=''%s''' , @ cols , @ tb , @ wherecol , @ value
    exec (@ s)
end
go
exec p_selec


Ïà¹ØÎĵµ£º

ÀûÓÃSQLSERVERµÄʼþ̽²âÆ÷ÕÆÎÕÓÃÓÑϵͳµÄ±í½á¹¹

SQLSERVERµÄʼþ̽²âÆ÷ÊÇÒ»¸öºÜÇ¿´óºÜÖ±¹ÛµÄ¹¤¾ß£¬µ±ÎÒÃÇÔÚERPϵͳÀïÃæ×öÒ»¶¨²Ù×÷µÄʱºò£¬¶¼»áÔÚÊý¾Ý¿âÀïÃæÐγɲéѯ»òÕßÔöɾ¸ÄµÄT-SQLÓï¾ä¡£Í¨¹ýʼþ̽²âÆ÷¾Í¿ÉÒÔÖªµÀERPÀïÃæµÄµ¥¾ÝÔÚÊý¾Ý¿âµÄÄĸö±íÀïÃ棬ÉõÖÁÄĸö×Ö¶ÎÀïÃæ¡£»¹¿ÉÒÔ¸ù¾Ý̽²âµ½µÄSQLÓï¾ä·ÖÎöERPϵͳµÄ±í½á¹¹£¬±íÖ®¼äµÄ¹ØÁª×Ö¶ÎÊÇÄĸö¡£
´ó¼Ò³õ´ò¿ªÊ¼þ̽²âÆ÷ ......

´¿JSP·ÖÒ³´úÂëÖ®sqlserver2005/2008

ÉÏһƪ·ÖÒ³ÎÄÕ£¬ÊÇÓÃÓÚmysql£¬ÉÔ΢ÐÞ¸ÄÏ£¬ÓÃÓÚSqlserver2005/2008£¬Ã»ÓÐÒì³£´¦Àí¡£Ã»Óп¼ÂÇÐÔÄܵȡ£
ÏÖ½«´úÂëÌù³ö£¬ÒÔ¹©³õѧÕ߲ο¼£º
×¢£ºÑûÔÂʹÓû·¾³Eclipse 3.4.2+Tomcat 6.18+Sqlserver2005 sp3µ÷ÊԳɹ¦¡£
Ò³ÃæpagelistDemo.jspÄÚÈÝ£º
Code
<%@ page language="java" contentType="text/html; ......

SQLServer¸ß¼¶±à³Ì

         ±¾ÆªÄÚÈÝϵÊôSQLServer¸ß¼¶±à³Ì£¬ÊÊÓÃÓÚÓûÌá¸ß×Ô¼ººÍ¸´Ï°»òÓ¦¸¶ÃæÊÔµÄÅóÓÑÔĶÁ£¬Í¬Ê±±¾ÈËѧϰ²»¾Ã£¬ÔÚ×ܽáºÍ¹éÄÉʱ´íÎóºÍ²»Ç¡µ±Ö®´¦ÔÚËùÄÑÃ⣬»¹ÇëÖ¸³öÆäÖБ¶ËÄß’£¬ÓèÒÔÍêÉÆ¡£
±í1:Users
USE [Wish]
GO
/****** ¶ÔÏó: Table [dbo].[Users] ½Å±¾ÈÕÆÚ: ......

»ñÈ¡sqlserverÊý¾Ý¿âÖÐËùÓп⡢±í¡¢×Ö¶ÎÃûµÄ·½·¨

»ñÈ¡sqlserverÊý¾Ý¿âÖÐËùÓп⡢±í¡¢×Ö¶ÎÃûµÄ·½·¨
2009Äê03ÔÂ12ÈÕ ÐÇÆÚËÄ ÏÂÎç 12:51
1.»ñÈ¡ËùÓÐÊý¾Ý¿âÃû:
SELECT Name from Master..SysDatabases ORDER BY Name
2.»ñÈ¡ËùÓбíÃû:
SELECT Name from DatabaseName..SysObjects Where XType='U' ORDER BY Name
XType='U':±íʾËùÓÐÓû§±í;
XType='S':±íʾËùÓÐϵͳ± ......

18¾ä»°ÈëÃÅSQLServer XML


/*
sql xml ÈëÃÅ:
    --by jinjazz
    --http://blog.csdn.net/jinjazz
   
    1¡¢xml:        ÄÜÈÏʶԪËØ¡¢ÊôÐÔºÍÖµ
   
    2¡¢xpath:    Ñ°Ö·ÓïÑÔ£¬ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ