sql µ¼³ö£¬½â¾ösheet±í´óСÏÞÖÆ
CREATE proc sqlToMultiExcelFile
@sqlstr nvarchar(4000), --²éѯÓï¾ä,Èç¹û²éѯÓï¾äÖÐʹÓÃÁËorder by ,Çë¼ÓÉÏtop 100 percent
@primaryKey varchar(100),--·ÖÒ³Ö÷¼ü×Ö¶Î
@path nvarchar(1000), --Îļþ´æ·ÅĿ¼
@fname nvarchar(250), --ÎļþÃû
@sheetname varchar(250)='sheet1' --Òª´´½¨µÄ¹¤×÷±íÃû,ĬÈÏΪÎļþÃû
as
set nocount on
declare @err int,@src nvarchar(255),@out int,@desc nvarchar(255),@sheetCount int,@i int,@topCount int,@where varchar(1000),@from varchar(1000),@myWhere varchar(1000),@filename varchar(250)
declare @obj int,@constr nvarchar(1000),@sql varchar(8000),@fdlist varchar(8000),@totalCount int,@pageCount int
create table #tbMemory
(
recId int identity(1,1) primary key,
primaryKey varchar(50)
)
create table #pageTb(totalCount int)
set @from=substring(@sqlstr,charindex('from',@sqlstr)+5,len(@sqlstr)-charindex('from',@sqlstr)+1)
if charindex('where',@sqlstr)>0
set @where=substring(@sqlstr,charindex('where',@sqlstr)+6,len(@sqlstr)-charindex('where',@sqlstr)+1)
else
set @where=''
set @pageCount=65000
set @sql='select count(*) from ('+@sqlStr+') a'
insert into #pageTb execute (@sql)
select @totalCount=totalCount from #pageTb
insert into #tbMemory execute('select top '+@totalCount+' '+@primaryKey+' from '+@from)
--µÃ³öÒªµ¼³öµÄsheetÊýÁ¿
if @totalCount>@pageCount
set @sheetCount=@totalCount/@pageCount+1
else
set @sheetCount=1
--²ÎÊý¼ì²â
if isnull(@fname,'')='' set @fname='temp.xls'
if isnull(@sheetname,'')='' set @sheetname=replace(@fname,'.','#')
--¼ì²éÎļþÊÇ·ñÒѾ´æÔÚ
if right(@path,1)<>'\' set @path=@path+'\'
create table #tb(a bit,b bit,c bit)
--´´½¨±íµÄSQL
declare @tbname sysname
set @tbname='##tmp_'+convert(varchar(38),newid())
set @sql='select top 1 * into ['+@tbname+'] from('+@sqlstr+') a'
--print @sql
exec(@sql)
select @sql='',@fdlist=''
select @fdlist=@fdlist+',['+a.name +']'
,@sql=@sql+',['+a.name+'] '
+ca
Ïà¹ØÎĵµ£º
ΪÁË´¦Àí SQL Óï¾ä£¬ORACLE ±ØÐë·ÖÅäһƬ½ÐÉÏÏÂÎÄ( context area )µÄÇøÓòÀ´´¦ÀíËù±ØÐèµÄÐÅÏ¢£¬ÆäÖаüÀ¨Òª´¦ÀíµÄÐеÄÊýÄ¿£¬Ò»¸öÖ¸ÏòÓï¾ä±»·ÖÎöÒÔºóµÄ±íʾÐÎʽµÄÖ¸ÕëÒÔ¼°²éѯµÄ»î¶¯¼¯(active set)¡£
ÓαêÊÇÒ»¸öÖ¸ÏòÉÏÏÂÎĵľä±ú( handle)»òÖ¸Õ롣ͨ¹ýÓα꣬PL/SQL¿ÉÒÔ¿ØÖÆÉÏÏÂÎÄÇøºÍ´¦ÀíÓï¾äʱÉÏÏÂÎÄÇø»á·¢ÉúЩʲôÊÂÇ ......
TA:
1,WANG
2,ZHANG
4,LI
TB:
1,100
2,200
3,400
1.left join ×óÁ¬½Ó--ÒÔ×ó±íΪ»ù×¼£¬ÓÒ±íÖÐûֵµÄ£¬ÔÚ½á¹û¼¯ÖÐÒÔnullÖµ´úÌæ¡£(select * from TA left join TB where TA.ID=TB.ID)
1,WANG,100
2,ZHANG,200
4,NULL
2.right join ÓÒÁ¬½Ó--ÒÔÓÒ±íΪ»ù×¼£¬×ó±íÖÐûֵµÄ£¬ÔÚ ......
http://blog.csdn.net/java2000_net/archive/2008/04/05/2252640.aspx
http://sqlserver.chinahtml.com/2006/SQL-mssql11432786154012.shtml
http://www.cnblogs.com/garnai/archive/2007/09/19/898221.html
http://tech.ccidnet.com/art/1099/20050223/214511_1.html
http://www.wangchao.net.cn/bbsdetail_43009.html ......
ÏÂÃæÊÇÖ¸µ¼Îĵµ¡£Çë¸ú×ÅÒ»²½²½µÄ×ö¡£¾ÍÄܳɹ¦Á¬½ÓÉÏsql server 2008
javaÖÐÁ¬½Ósql server 2008µÄ×¢ÒâÊÂÏ
2000£¬2005µÄÊý¾Ý¿âÇý¶¯ÀàµÄд·¨ÊÇ£º
com.microsoft.jdbc.sqlserver.SQLServerDriver
URLµÄд·¨ÊÇ£º¼ÙÉèÊý¾Ý¿âÊÇnews
jdbc:microsoft:sqlserver://localhost:1433;databaseName=news
µ«ÊÇ20 ......
³£ÓÃSQL²éѯ£º
1¡¢²é¿´±í¿Õ¼äµÄÃû³Æ¼°´óС
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
2¡¢²é¿´±í¿Õ¼äÎïÀíÎļþµÄÃû³Æ¼°´óС
select tablespace_name, file_id, ......