sqlµãµÎ
×Ó±í²éѯ£¬¸¸±íÒ»¶¨Òª¼Ó±ðÃû£¬·ñÔòÊý¾Ý»áÓÐÎÊÌ⣬²»±¨±àÒë´í
select * from table1 a where exist(select 1 from table2 where a.id=b.id)
´æ´¢¹ý³Ì½á¹û¼¯²åÈëµ½ÏÖÓбí
insert into table1 exec procname args
ÁªºÏÒÑÓÐ±í£¬½ô¸úÔÚºóÃ棬¶Ô»ã×ܺÜÓÐÓÃ
select a from table1 union all select 'ºÏ¼Æ'
½á¹û¼¯ÀïµÄijÁÐÏà¼Ó
declare @var nvarchar(1000)
set @var=''
select @var=@var+','+alarmname from notice where args=@args
print @var
shellÃüÁî
declare @cmd nvarchar(1000)
set @cmd='bcp "select cellphone,msg from atm.dbo.sendoutmsg" queryout '+@outfile+' -c -q -t "|" -U'+@sqluser+' -P'+@sqlpwd +' -S'+@server
EXEC master..xp_cmdshell @cmd ,NO_OUTPUT
(
@cmd ¿ÉÒÔÊÇ£º
dir c:\ c:\dir_out.txt
del c:\deposit.htm
copy c:\resource\deposit.htm c:\
move c:\µ¹Èë0911.xls d:\µ¹Èë0911.xls
)
´óÈÝÁ¿Êý¾Ýµ¼Èë(ÒÔ\r\nΪÊý¾ÝÐнáβ,|ΪÁзָî·û)
DECLARE @bulk_cmd varchar(1000);
SET @bulk_cmd = 'BULK INSERT dbo.tmpbasedevinfo from ''D:\dev_bmsg.txt''
with (FIELDTERMINATOR =''|'',
ROWTERMINATOR = '''+CHAR(10)+''')';
exec(@bulk_cmd);
ÅжÏÎļþÊÇ·ñ´æÔÚ
create table #tb(a bit,b bit,c bit)
insert into #tb exec master..xp_fileexist 'c:\furniture.txt'
if exists(select * from #tb where a=1)
PRINT Îļþ´æÔÚ
else
PRINT Îļþ²»´æÔÚ
drop table #tb
Ïà¹ØÎĵµ£º
Á¬½Ósql serverÊý¾Ý¿âÓõ½µÄÃüÃû¿Õ¼äÊÇusing System.Data.SqlClient;
Êý¾Ý¿âÁ¬½Ó´úÂë:¿ÉÒÔÔÚ´óÀàÖ®ÏÂÉùÃ÷ public SqlConnection myConnection; //sqlÁ¬½Ó¶ÔÏó
&nbs ......
SQL> select * from dept where deptno=&tt;
Enter value for tt:20
DEPTNO DNAME LOC
------ -------------- -------------
10 ACCOUNTING NEW YORK
ÕâÑùÎÞÂÛÊäÈë¶àÉÙ´ÎttµÄÖµ£¬ÏµÍ³Ö»½¨Á¢Ò»¸öÖ´Ðмƻ®£¬Ì ......
֮ǰʹÓÃPLSQL£¬¶¼ÊÇÒÔдÈëÄÚÈÝΪÖ÷£¬Ð´ÈëÖÐÎÄÄÚÈÝżÓÐÂÒÂ룬µ«ÊÇÖ»ÔÚÏÔʾÉϲ¢Î´Ó°Ïì´æÈ¡£¬ËùÒÔûÓÐÔÚÒâ¡£
½ñÌìÔÚÐÞ¸ÄÒ»¸öÊÓͼʱ£¬ÐèÒª½«ÐÞ¸ÄÄÚÈݼǼÏÂÀ´£¬so,Ïëд¸öÐ޸ļǼ£¬¾Í°ÑÊÓͼÄÚÈÝ¿½±´Á˳öÏÖ£¬·¢ÏÖ¿½±´³öÏÖµÄÖÐÎÄÄÚÈݳöÏÖÂÒÂë¡£
²¢Î´ÍêÈ«ÔÚÒ⣬ÒÔΪֻҪÔÑù·Å»Øplsql¾Í»áºÃµÄ£¬µ«ÊDZ£´æÔÙÈ¡³ö·Åµ½plsqlÖз¢ÏÖÈÔ ......
±³¾°:
sql select top N Óï¾äÊÇÒ»¸ö·Ç³£ÖØÒªµÄÓï¾ä, ÔÚʵÏÖ·ÖÒ³²éѯÖÐÊDz»¿É»òȱµÄ. ÓÉÓÚ·ÖÒ³²éѯͨ³£Éæ¼°º¬ÓдóÁ¿¼Ç¼µÄ±í£¬ ²¢ÇÒÊÇΪ´óÁ¿Óû§·ÖÏíµÄÈÎÎñ£¬Òò´Ë£¬¶ÔÆä½øÐÐÓÅ»¯ÊǺÜÓÐÒâÒåµÄ¡£
ʵÏÖsql top N µÄ¹¦ÄÜÓм¸ÖÖ±äÖÖ£º
1. set rowcount @n; select ... order by somefields
2. select top (@n) .... order by ......
package cn.com.hbivt.util;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class StringUtils {
//¹ýÂËͨ¹ýÒ³Ãæ±íµ¥Ìá½» ......