易截截图软件、单文件、免安装、纯绿色、仅160KB

某外企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


相关文档:

SQL语句导入导出

SQL语句导入导出
/******* 导出到excel
EXEC master..xp_cmdshell 'bcp SettleDB.dbo.shanghu out c:\temp1.xls -c -q -S"GNETDATA/GNETDATA" -U"sa" -P""'
/*********** 导入Excel
SELECT *
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\test.xls";User ID=Admin;Password=;Extended propert ......

通过分析SQL语句的执行计划优化SQL(一)

优化器在形成执行计划时需要做的一个重要选择是如何从数据库查询出需要的数据。对于SQL语句存取的任何表中的任何行,可能存在许多存取路径(存取方法),通过它们可以定位和查询出需要的数据。优化器选择其中自认为是最优化的路径。
  在物理层,oracle读取数据,一次读取的最小单位为数据库块(由多个连续的操作系统块组成 ......

Sql Server 生成数据字典

use Dbname  
go  
select   
    [表名]=c.Name,  
    [表说明]=isnull(f.[value],''),  
    [列名]=a.Name,  
    [列序號]=a.Column_id,  
 &nbs ......

SQL Server中六种数据移动的方法

1.通过工具DTS的设计器进行导入或导出
DTS的设计器功能强大,支持多任务,也是可视化界面,容易操作,但知道的人一般不多,如果只是进行SQL Server数据库中部分表的移动,用这种方法最好,当然,也可以进行全部表的移动。在SQL Server Enterprise Manager中,展开服务器左边的+,选择数据库,右击,选择All tasks/Import ......

SQL 常用语句

1、表操作。
1.1 现有表增加字段
alter table TableName add  
       columnName1  varchar(2) NULL,
       columnName2 varchar(2) NULL,
       columnName3 varchar(2) NULL
注意:不用加Colu ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号