SQL´æ´¢¹ý³Ì²âÊÔ£¨4£©——´´½¨T
ÎÊÌâ
ÈçºÎ´´½¨Ò»¸öT-SQL²âÊÔÌ×¼þÓÃÓÚ²âÊÔSQL´æ´¢¹ý³Ì¡£
Éè¼Æ
Ê×ÎÞ£¬Í¨¹ý²åÈë´óÁ¿²âÊÔƽ̨Êý¾Ý×¼±¸ºÃÒ»¸ö°üº¬´ý²â´æ´¢¹ý³ÌµÄµ×²ãÊý¾Ý¿â¡£½ÓÏÂÀ´£¬Ê¹ÓÃÒ»¸öSQLÓαê(cursor)±éÀúÕâ¸ö²âÊÔÓÃÀýÊý¾Ý±í¡£Õë¶Ôÿ¸ö²âÊÔÓÃÀý£¬µ÷Óôý²â´æ´¢¹ý³Ì²¢ÇÒÈ¡µÃËüµÄ·µ»ØÖµ£¬°Ñʵ¼Ê·µ»ØÖµÓëÆÚÍûÖµ½øÐбȽϣ¬´Ó¶øÅж¨²âÊÔ½á¹ûÊÇͨ¹ýÓë·ñ£¬È»ºóÏÔʾ»ò±£´æ²âÊÔ½á¹û¡£
·½°¸
——testAuto.sql
——ΪdbEmployeesÌî³äÊý¾Ý
truncate table dbEmployees.dbo.tblEmployees
insert into dbEmployees.dbo.tblEmployees values('e11','Adams','15/10/2009')
insert into dbEmployees.dbo.tblEmployees values('e22','Baker','15/10/2009')
insert into dbEmployees.dbo.tblEmployees values('e33','Young','15/10/2009')
insert into dbEmployees.dbo.tblEmployees values('e44','Zetta','15/10/2009')
——´Ë´¦²åÈë¸ü¶àÊý¾Ý
declare tCursor cursor fast_forward
for select caseID,input,expected
from dbTestCasesAndResults.dbo.tblTestCases
order by caseID
declare @caseID char(4),@input char(3),@expected int
declare @actual int,@whenRun datetime
declare @resultLine varchar(50)
set @whenRun = getdate()
open tCursor
fetch next
from tCursor
into @caseID,@input,@expected
while @@fetch_status = 0
begin
exec @actual = dbEmployees.dbo.usp_StatusCode @input
if (@actual = @expected)
begin
set @resultLine = @caseID + ': Pass'
print @resultLine
end
else
begin
set @resultLine = @caseID + ': FAIL'
&nbs
Ïà¹ØÎĵµ£º
2¡¢sql express °²×° Èç¹ûÔÚXPÏ£¬Ö±½ÓË«»÷°²×°¾ÍºÃÁË¡£ ÏÈ°²×° [ÔÚvistaÏÂÈç¹ûÖ±½ÓË«»÷¿ÉÄÜ»á³öÏÖ °²×°sql server express ³ö´í29506 ] [Vista°²×°µÄʱºò£¬ÐèҪʹÓá°ÒÔ¹ÜÀíÔ±Éí·ÝÔËÐС±°²×°] SQLServer2005_SSMSEE.msi°²×°½áÊø studioÒѾ°²×°ÉÏÈ¥£¬µ«ÊÇÄãÓÐûÓз¢ÏÖ£¬°²×°sqlµÄʱºòûÓз¢ÏÖÓÐÓû§saµÄà ......
SQL´¥·¢Æ÷ʵÀý1
¶¨Ò壺 ºÎΪ´¥·¢Æ÷£¿ÔÚSQL ServerÀïÃæÒ²¾ÍÊǶÔijһ¸ö±íµÄÒ»¶¨µÄ²Ù×÷£¬´¥·¢Ä³ÖÖÌõ¼þ£¬´Ó¶øÖ´ÐеÄÒ»¶Î³ÌÐò¡£´¥·¢Æ÷ÊÇÒ»¸öÌØÊâµÄ´æ´¢¹ý³Ì¡£
³£¼ûµÄ´¥·¢Æ÷ÓÐÈýÖÖ£º·Ö±ðÓ¦ÓÃÓÚInsert , Update , Delete ʼþ¡£
ÎÒΪʲôҪʹÓô¥·¢Æ÷£¿±ÈÈ磬 ......
character-set-server = GB2312
collation-server = latin1_general_ci
MySQL×Ö·û¼¯ GBK¡¢GB2312¡¢UTF8Çø±ð ½â¾ö MYSQLÖÐÎÄÂÒÂëÎÊÌâ ÊÕ²Ø
MySQLÖÐÉæ¼°µÄ¼¸¸ö×Ö·û¼¯
character-set-server/default-character-set£º·þÎñÆ÷×Ö·û¼¯£¬Ä¬ÈÏÇé¿öÏÂËù²ÉÓõġ£
character-set-database£ºÊý¾Ý¿â×Ö·û¼¯¡£
character-set-table£ºÊ ......
SQLÖ®ÐÐÁл¥±äÎÊÌâ¡£
Ñ°Ñ°ÃÙÃÙ£¬SQLÐбäÁУ¬ÁбäÐÐÎÊÌâËäÈ»½â¾ö·½°¸Öڶ࣬µ«ÎÞ²»´æÔÚ×Å´úÂ븴ÔÓ£¬ÐÔÄÜÇ·¼ÑµÈÎÊÌâ¡£½ñÓÐÐÒµÃÖª×î¼Ñ½â¾ö·½°¸£¬ºÃ¶«Î÷²»¸Ò¶ÀÏí£¬±Ê¼ÇÖ®£¬ÑÅË×¹²ÉÍ¡£
ʾÀýÊý¾Ý£º£¨¸ÃʾÀýÊý¾ÝÀ´×ÔYHHRÊý¾Ý¿â Performance_Zmonth_Value±í£©
Employee_Id& ......
--½«ÏµÍ³datediffº¯ÊýÖØд£¬Ö÷Òª°ÑdatepartÀàÐ͸ÄΪvarhcar£¬·½±ãµ÷ÓÃ
--×÷Õß:°½Ê¿Î°
--Date:2009-10-14 10:29
create function MyDateDiff(@datepart varchar(50), --ÈÕÆÚ¼ä¸ôÀàÐÍ:year,month,day.etc
@date1 varchar(50), @date2 varchar(50))
returns int
as
begin
declare @part int
if @datepart ......