ijÍâÆóSQL ServerÃæ試題
--> Title : ijÍâÆóSQL ServerÃæ試題
--> Author : wufeng4552
--> Date : 2010-1-15
Question 1£ºCan you use a batch SQL or store procedure to calculating the Number of Days in a Month
Answer 1£ºÕÒ³öµ±ÔµÄÌìÊý
select datepart(dd,dateadd(dd,-1,dateadd(mm,1,cast(cast(year(getdate()) as varchar)+'-'+cast(month(getdate()) as varchar)+'-01' as datetime))))
Question2£ºCan you use a SQL statement to calculating it!
How can I print "10 to 20" for books that sell for between $10 and $20£¬"unknown" for books whose price is null, and "other" for all other prices?
Answer 2£º
select bookid,
bookname,
price=case when price is null then 'unknown'
when price between 10 and 20 then '10 to 20'
else price
end
from books
Question3£ºCan you use a SQL statement to finding duplicate values!
How can I find authors with the same last name?You can use the table authors in datatabase pubs. I want to get the result as below:
Output:
au_lname number_dups
---------------------------------------- -----------
Ringer 2
(1 row(s) affected)
Answer 3:
select au_lname,
number_dups=count(1)
from authors
group by au_lname
Question4£ºCan you create a cro
Ïà¹ØÎĵµ£º
Ò»¡¢Êʺ϶ÁÕß¶ÔÏó£ºÊý¾Ý¿â¿ª·¢³ÌÐòÔ±£¬Êý¾Ý¿âµÄÊý¾ÝÁ¿ºÜ¶à£¬Éæ¼°µ½¶ÔSP£¨´æ´¢¹ý³Ì£©µÄÓÅ»¯µÄÏîÄ¿¿ª·¢ÈËÔ±£¬¶ÔÊý¾Ý¿âÓÐŨºñÐËȤµÄÈË¡£ ¡¡
¶þ¡¢½éÉÜ£ºÔÚÊý¾Ý¿âµÄ¿ª·¢¹ý³ÌÖУ¬¾³£»áÓöµ½¸´ÔÓµÄÒµÎñÂß¼ºÍ¶ÔÊý¾Ý¿âµÄ²Ù×÷£¬Õâ¸öʱºò¾Í»áÓÃSPÀ´·â×°Êý¾Ý¿â²Ù×÷¡£Èç¹ûÏîÄ¿µÄSP½Ï¶à£¬ÊéдÓÖûÓÐÒ»¶¨µÄ¹æ·¶£¬½«»áÓ°ÏìÒÔºóµÄϵͳά»¤ ......
ÓÅ»¯Æ÷ÔÚÐγÉÖ´Ðмƻ®Ê±ÐèÒª×öµÄÒ»¸öÖØÒªÑ¡ÔñÊÇÈçºÎ´ÓÊý¾Ý¿â²éѯ³öÐèÒªµÄÊý¾Ý¡£¶ÔÓÚSQLÓï¾ä´æÈ¡µÄÈκαíÖеÄÈκÎÐУ¬¿ÉÄÜ´æÔÚÐí¶à´æÈ¡Â·¾¶(´æÈ¡·½·¨)£¬Í¨¹ýËüÃÇ¿ÉÒÔ¶¨Î»ºÍ²éѯ³öÐèÒªµÄÊý¾Ý¡£ÓÅ»¯Æ÷Ñ¡ÔñÆäÖÐ×ÔÈÏΪÊÇ×îÓÅ»¯µÄ·¾¶¡£
¡¡¡¡ÔÚÎïÀí²ã£¬oracle¶ÁÈ¡Êý¾Ý£¬Ò»´Î¶ÁÈ¡µÄ×îСµ¥Î»ÎªÊý¾Ý¿â¿é(Óɶà¸öÁ¬ÐøµÄ²Ù×÷ϵͳ¿é×é³É ......
use Dbname
go
select
[±íÃû]=c.Name,
[±í˵Ã÷]=isnull(f.[value],''),
[ÁÐÃû]=a.Name,
[ÁÐÐò號]=a.Column_id,
&nbs ......
×î½üÔÚ×öÒ»¸ö×¢²á³ÌÐò£¬µÃÓõÃÃÜÂëµÄMD5¼ÓÃÜ£¬Ö±½ÓÔÚ´æ´¢¹ý³ÌÖнøÐÐ×¢²á¡£
²éÕҵõ½£¬¿ÉÓÃÒÔÏ·½·¨½øÐмÓÃÜ£º
print RIGHT(sys.fn_VarBinToHexStr(hashbytes('MD5','ANSEN')),32)
Êý¾Ý¿âÊÇÓÃSQL SERVER 2005£¬ÆäËûµÄÊý¾Ý¿âÓ¦¸ÃÒ²²î²»µ½ÄÄÈ¥~~ ......
ת×Ô£ºhttp://news.newhua.com/news1/program_database/2008/530/0853093226E2KJ93C02415FEB1CD9A5HCKA821556279EEKJ7728GI5.html
ÊÂÎñÈÕÖ¾ÎļþTransaction Log FileÊÇÓÃÀ´¼Ç¼Êý¾Ý¿â¸üÐÂÇé¿öµÄÎļþ£¬À©Õ¹ÃûΪldf¡£
ÔÚ SQL Server 7.0 ºÍ SQL Server 2000 ÖУ¬Èç¹ûÉèÖÃÁË×Ô¶¯Ôö³¤¹¦ÄÜ£¬ÊÂÎñÈÕÖ¾Îļþ½«»á×Ô¶¯À©Õ¹¡£
Ò»° ......