Åú´¦ÀíSQL Îļþ
@echo off
rem Input Parameters:
rem 1 -Server Name
rem 2 -Database Name
if "%1"=="" goto ERROR
if "%2"=="" goto ERROR
@rem Make variables local
@Setlocal
@rem set variables from input parameters
set Server=% 1
set DBName=% 2
@rem---------------------------------------------------------------
set LOGFILE=buildDB.log
rem---------------------------------------------------------------
if exist %LOGFILE% del %LOGFILE%
echo--------------------BEGIN %0 -------------------------------------
time/t
echo -----------------BEGIN %0---------------->>%LOGFILE%
time/t>>%LOGFILE%
@rem Create Database
echo Create Database
echo Create Database>>%LOGFILE%
osql -S %Server% -d master -i createdatabase.sql -n -b -w2048>>%LOGFILE%
@rem Create Tables
echo Create Tables
echo Create Tables>>%LOGFILE%
for % %i in(Table\*.sql) do call :osql "% %i"
@rem Create Constraints
echo Create Constraints
echo Create Constraints>>%LOGFILE%
for % %i in(Table\Constraints\*.sql) do call :osql "% %i"
@rem Create Triggers
echo Create Triggers
echo Create Triggers>>%LOGFILE%
for % %i in(Table\Triggers\*.sql) do call :osql "% %i"
@rem Create Indexes
echo Create Indexes
echo Create Indexes>>%LOGFILE%
for % %i in(Table\Indexes\*.sql) do call :osql "% %i"
@rem Create Views
echo Create Views
echo Create Views>>%LOGFILE%
for % %i in(Table\Views\*.sql) do call :osql "% %i"
@rem Create SPs
echo Create SPs
echo Create SPs>>%LOGFILE%
for % %i in(Table\SPs\*.sql) do call :osql "% %i"
@rem Create Functions
echo Create Functions
echo Create Functions>>%LOGFILE%
for % %i in(Table\Functions\*.sql) do call :osql "% %i"
goto DONE
:ERROR
Echo All 2 parameters (Server name ,CMDB database name) must be supplied as parameters.
Echo---------------------------------------------------------
Echo USAGE: %0 [Server] [database]
Echo------------------------------------------------------------
:ERROREXIT
echo-----
Ïà¹ØÎĵµ£º
¡¾IT168 ¼¼Êõ·ÖÎö¡¿ÔÚÏò2009Äê¸æ±ðÖ®¼Ê£¬ÎÒÃÇÀ´»Ø¹ËһϹýÈ¥µÄÒ»ÄêÖÐ×îÊÜ»¶ÓµÄSQL Server¼¼ÇÉ£¬°üÀ¨ÁËOPENROWSET¡¢FILESTREAMµÈº¯ÊýµÄÓ÷¨¡¢ÃÜÂ빤¾ß½éÉÜÒÔ¼°DBAÈÕ³£¹¤×÷½¨ÒéµÈÄÚÈÝ¡£
¡¡¡¡Í¨¹ý¶ÔÕâЩ¾«»ªÎÄÕµÄÔٴλعˣ¬Ï£Íû¿ÉÒÔ°ïÖúÄúÊáÀíÒ»ÏÂÕâÒ»ÄêÒÔÀ´µÄ¹¤×÷ÒÔ¼°Ñ§Ï°Ðĵ㬶ÔδÀ´Ò»Äê¸ü½øÒ»²½´òϸü¼áʵµÄ»ù´¡¡£
¡¡¡ ......
Ò»¡¢Êʺ϶ÁÕ߶ÔÏó£ºÊý¾Ý¿â¿ª·¢³ÌÐòÔ±£¬Êý¾Ý¿âµÄÊý¾ÝÁ¿ºÜ¶à£¬Éæ¼°µ½¶ÔSP£¨´æ´¢¹ý³Ì£©µÄÓÅ»¯µÄÏîÄ¿¿ª·¢ÈËÔ±£¬¶ÔÊý¾Ý¿âÓÐŨºñÐËȤµÄÈË¡£ ¡¡
¶þ¡¢½éÉÜ£ºÔÚÊý¾Ý¿âµÄ¿ª·¢¹ý³ÌÖУ¬¾³£»áÓöµ½¸´ÔÓµÄÒµÎñÂß¼ºÍ¶ÔÊý¾Ý¿âµÄ²Ù×÷£¬Õâ¸öʱºò¾Í»áÓÃSPÀ´·â×°Êý¾Ý¿â²Ù×÷¡£Èç¹ûÏîÄ¿µÄSP½Ï¶à£¬ÊéдÓÖûÓÐÒ»¶¨µÄ¹æ·¶£¬½«»áÓ°ÏìÒÔºóµÄϵͳά»¤ ......
ch02
--3-4
select * from orders
where 'México D.F.' in
(select City
from Customers
where Orders.CustomerID = Customers.CustomerID )
--3-5
select * from orders
where 'usa' =
(select Country
from Customers
where Orders.CustomerID = Customers.CustomerID )
--4-1
select * from or ......
×î½üÓõ½ÈÕÆÚ·¶Î§µÄ²éѯ£¬Óõ½ÁËbetween£¬µ«ÊÇ·¢ÏÖÈç¹ûÈÕÆÚ´øʱ¼äµÄ»°£¬BETWEEN '2010-1-4' AND
'2010-1-4'ÕâÑùµÄÓï¾äÊDz鲻µ½Êý¾ÝµÄ£¬ºóÀ´Ïëµ½ÁËÒ»ÖָĽø·½·¨£¬¹©´ó¼Ò²Î¿¼¡£
ÈçÏ£º
BETWEEN '2010-1-4' AND DATEADD(day, 1, '2010-1-4')
ÓÃÁËDATEADDÒÔºó£¬Ð§¹ûºÜ²»´í ......
¶ÔͬһÕűí½øÐÐÁ½ÖÖ·½Ê½²éѯ£¨½á¹û¼¯Ïàͬ£©£º
case1 ²éѯÌõ¼þ:°üÀ¨¼ÆËã»úÃû£¬êdzƣ¬Ìí¼Óʱ¼äµÈµÈһЩÏÞÖÆÌõ¼þ×ֶΡ£¶øÇÒÐèÁª±í²éѯ±ðµÄ±í
²éѯÊý¾ÝÁ¿£º 100Íò 200Íò
µ¥´¿Ö´ÐÐSQLÓï¾äËùÐèʱ¼ä£º31ºÁÃë&nbs ......