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

MSSQL
mssql server 存储过程里,bulk insert table from ''路径+文件'',路径固定,文件名不固定的实现方法
请问在mssql“SQL事件探查器”里表格的标题,如CPU,Read,Write,Duration,SPID.........的解释
mssql server .ldf和.mdf的文件附加数据库的sql语句
[js]javascript与剪贴板交互
mssql中得到当天数据的语句
在SQL中使用convert函数进行日期的查询的代码
sql server中datetime字段去除时间的语句
sql语句优化之用EXISTS替代IN、用NOT EXISTS替代NOT IN的语句
推荐SQL Server 重新恢复自动编号列的序号的sql代码
清空MSSQL日志 与set recovery simple
mssql2005注入方法小结
[原创]比较详细的完美解决安装sql2000时出现以前的某个程序安装已在安装计算机上创建挂起的文件操作。
sql语句中如何将datetime格式的日期转换为yy-mm-dd格式
重装MS SQL Server 2000前必须彻底删除原安装文件的方法
SQL Server 不删除信息重新恢复自动编号列的序号的方法
MSSQL差异备份取系统权限的相关软件下载
解决MSSQL2005远程连接sql2000非默认端口数据库的问题
SQL命令大全-中英文对照
用SQL语句实现随机查询数据并不显示错误数据的方法
sql server不存在 sql server拒绝访问

MSSQL 中的 某外企SQL Server面试题


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 47 ::
收藏到网摘: 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