WEB开发网
开发学院数据库MSSQL Server 某外企SQL Server面试题 阅读

某外企SQL Server面试题

 2007-05-17 09:38:26 来源:WEB开发网   
核心提示: Tips: sp_recompile can recomplie a store procedure each timeAnswer 5:在执行存储过程时,使用 with recompile 选项强制编译新的计划;使用sp_recompile系统存储过程强制在下次运行时进行重新编译Ques

Tips: sp_recompile can recomplie a store procedure each time

Answer 5:在执行存储过程时,使用 with recompile 选项强制编译新的计划;使用sp_recompile系统存储过程强制在下次运行时进行重新编译

Question6: How can I add row numbers to my result set?

In database pubs, have a table titles , now I want the result shown as below,each row have a row number, how can you do that?

Result:

line-no   title_id
----------- --------
1      BU1032
2      BU1111
3      BU2075
4      BU7832
5      MC2222
6      MC3021
7      MC3026
8      PC1035
9      PC8888
10     PC9999
11     PS1372
12     PS2091
13     PS2106
14     PS3333
15     PS7777
16     TC3218
17     TC4203
18     TC7777

Answer 6:

--SQL 2005的写法

select row_number() as line_no ,title_id from titles

--SQL 2000的写法

select line_no identity(int,1,1),title_id into #t from titles

select * from #t

drop table #t

Question 7: Can you tell me what the difference of two SQL statements at performance of execution?

Statement 1:

if NOT EXISTS ( select * from publishers where state = 'NY')

begin

SELECT 'Sales force needs to penetrate New York market'end

上一页  1 2 3 4 5  下一页

Tags:外企 SQL Server

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接