某外企SQL Server面試題
--> Title : 某外企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
相关文档:
系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......
最近在做一个注册程序,得用得密码的MD5加密,直接在存储过程中进行注册。
查找得到,可用以下方法进行加密:
print RIGHT(sys.fn_VarBinToHexStr(hashbytes('MD5','ANSEN')),32)
数据库是用SQL SERVER 2005,其他的数据库应该也差不到哪去~~ ......
1.通过工具DTS的设计器进行导入或导出
DTS的设计器功能强大,支持多任务,也是可视化界面,容易操作,但知道的人一般不多,如果只是进行SQL Server数据库中部分表的移动,用这种方法最好,当然,也可以进行全部表的移动。在SQL Server Enterprise Manager中,展开服务器左边的+,选择数据库,右击,选择All tasks/Import ......
1、表操作。
1.1 现有表增加字段
alter table TableName add
columnName1 varchar(2) NULL,
columnName2 varchar(2) NULL,
columnName3 varchar(2) NULL
注意:不用加Colu ......