易截截图软件、单文件、免安装、纯绿色、仅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 choch02

ch02
--3-4
select * from orders
where 'México D.F.' in
(select City
from Customers
where Orders.CustomerID = Customers.CustomerID )
--3-5
select * from orders
where 'usa' =
(select Country
from Customers
where Orders.CustomerID = Customers.CustomerID )
--4-1
select * from or ......

SQL Server 语句

1.SELECT语句从数据库中选取数据
SELECT '列名' from '表名' SELECT list_name from table_name 从 '表名' 选区'列名' 数据 SQL SELECT * from table_name 从 '表名' 选区全部数据
2.SELECT 加WHERE 语句
SELECT '列名' from '表名' WHERE '条件'
3.SELECT 加AS 语句
使用AS 给数据指定一个别名。此别名用来在表达式 ......

Sql Server 生成数据字典

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

批处理SQL 文件

@echo off
rem Input Parameters:
rem 1 -Server Name
rem 2 -Database Name
if "%1"=="" goto ERROR
if "%2"=="" goto ERROR
@rem Make variables local
@Setlocal
@rem set variables from input parameters
set Server=% 1
set DBName=% 2
@rem------------------------------------------------------------ ......

SQL 设计模式

1、SQL是一种说明性语言,不是过程化语言。类似“检索->检查->插入->更新”的过程化步骤的顺序是没有意义的。应该以行集的方式思考,以描述一个逻辑的语言方式思考。
2、在设计数据库表字段时,一个行描述应该包含一个事实,而且是全部事实。例如考勤卡的设计,
不要设计为:[ userId, puchTime, even ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号