SQL ºÏ²¢ÐУ¬·µ»Ø´ø·Ö¸ô×Ö·ûµÄ×Ö·û´®
--ºÏ²¢ÐУ¬²¢·µ»ØºÏ²¢µÄÖµ
Create proc [dbo].[proUniteRow]
@tab varchar(30), --±íÃû
@col varchar(30), --ºÏ²¢µÄÁÐÃû
@where varchar(2000), --ºÏ²¢µÄÌõ¼þ
@firstSplit varchar(100), --Á¬½Ó×Ö·ûǰ׺
@lastSplit varchar(100), --Á¬½Ó×Ö·ûºó׺
@order varchar(100), --ÅÅÐò
@val nvarchar(2000)='' output –·µ»ØÖµ
as
begin
declare @sql nvarchar(2000)
set @sql='
declare @retStr varchar(2000)
set @retStr=''''
declare cur cursor
read_only
for select
'+@col+' from '+@tab
if len(@where)>0
set @sql=@sql+' where '+@where
if len(@order)>0
set @sql=@sql+' order by '+@order
set @sql=@sql+'
declare @str varchar(2000)
open cur
fetch next from cur into @str
while (@@fetch_status =0)
begin
set @retStr=@retStr+'''+@firstSplit+'''+@str+'''+@lastSplit+'''
fetch next from cur into @str
end
close cur
deallocate cur
if len(@retStr)>0
set @strEnd=substring(@retStr,1,len(@retStr)-1)
'
exec sp_executesql @sql,N'@strEnd nvarchar(2000) output',@val output
end
Ö´ÐУº
±ípro_lbsxb:
ID lbsx_value lbsx_isList lbsx_order
1 A 1 1
2 B 1 2
3 C 1 3
4 D &
Ïà¹ØÎĵµ£º
Student(S#,Sname,Sage,Ssex) ѧÉú±í
Course(C#,Cname,T#) ¿Î³Ì±í
SC(S#,C#,score) ³É¼¨±í
Teacher(T#,Tname) ½Ìʦ±í
ÎÊÌ⣺
1¡¢²éѯ“001”¿Î³Ì±È“002”¿Î³Ì³É¼¨¸ßµÄËùÓÐѧÉúµÄѧºÅ£»
select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
fr ......
ÉÏ»Ø˵µ½£¬²Ù×÷Object Array
Æäʵ»¹¿ÉÒÔÕâÑù²Ù×÷£º
var Room = [
{
ID: 'bot',
name: 'test' ......
alert index mem_ct monitoring usage;
desc v$object_usage;
set linesize 190
select * from v$object_usage;
SQL>SET AUTOTRACE ON;
¡¡¡¡*autotrace¹¦ÄÜÖ»ÄÜÔÚSQL*PLUSÀïʹÓÃ
¡¡¡¡ÆäËûһЩʹÓ÷½·¨£º
¡¡¡¡2.2.1¡¢ÔÚSQLPLUSÖеõ½Óï¾ä×ܵÄÖ´ÐÐʱ¼ä
¡¡¡¡SQL> set timing on;
2.2.2¡¢Ö»ÏÔʾִÐмƻ®--(»áÍ¬Ê ......
1¡¢²éѯÁ½¸öʱ¼äÖ®¼ä
select * from [tablename] where date between \'value1\' and \'value2\'
2¡¢ÏÔʾ×îºó»Ø¸´Ê±¼ä
select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b
3¡¢Èճ̰²ÅÅÌáÇ°5·ÖÖÓÌáÐÑ
select * from Èճ̰²ÅÅ w ......
·ÖÒ³²éѯµÄÔÀí£º
Õâ¸öÖ»ÄÜÓÃÔÙSql2005¼°ÒÔÉϵİ汾
DECLARE @pagenum AS INT, @pagesize AS INT
SET @pagenum = 2
SET @pagesize = 3
SELECT *
from (SELECT ROW_NUMBER()&n ......