当前位置: 首页 > 图文教程 > 数据库 > MSSQL > 某外企SQL Server面试题

MSSQL
SQL注入漏洞全接触--进阶篇(二)
SQL注入漏洞全接触--高级篇(一)
SQL注入漏洞全接触--高级篇(二)
SQL Server补丁安装常见问题
[专题]SQL SERVER实用经验技巧集
防范SQL注入式攻击
Mssql和Mysql的安全性分析
SQL概述及在网络安全中的应用
安全入门:SQL注入漏洞全接触
数据库系统防黑客入侵技术综述
SQL注入奇招致胜 UNION查询轻松免费看电影
看紧你的3306端口,一次通过mysql的入侵
MSSQL db_owner角色注入直接获得系统权限
针对SQL INJECTION的SQL SERVER安全设置初级篇
有孔就入 SQL Injection的深入探讨
SQL注入不完全思路与防注入程序
SQL注入攻击的原理及其防范措施
SQL Server应用程序中的高级SQL注入
数据库下载漏洞攻击技术
SQL注入实战---利用“dbo”获得SQL管理权限和系统权限

MSSQL 中的 某外企SQL Server面试题


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 73 ::
收藏到网摘: n/a

Question 1:Can you use a batch SQL or store procedure to calculating the Number of Days in a Month
Answer 1:
找出当月的天数
selectdatepart(dd,dateadd(dd,-1,dateadd(mm,1,cast(cast(year(getdate()) asvarchar)+'-'+cast(month(getdate()) as varchar)+'-01' as datetime))))

Question2:Can you use a SQL statement to calculating it!
Howcan 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 otherprices?
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 cross-tab report in my SQL Server!
Howcan I get the report about sale quality for each store and each quarterand the total sale quality for each quarter at year 1993?
You can use the table sales and stores in datatabase pubs.
TableSales record all sale detail item for each store. Column store_id isthe id of each store, ord_date is the order date of each sale item, andcolumn qty is the sale qulity. Table stores record all storeinformation.
I want to get the result look like as below:
Output:

stor_name                                Total       Qtr1        Qtr2        Qtr3        Qtr4       
---------------------------------------- ----------- ----------- ----------- ----------- -----------
Barnum's                                 50          0           50          0           0
Bookbeat                                 55          25          30          0           0
Doc-U-Mat: Quality Laundry and Books     85          0