SQLѧϰ±Ê¼Ç
¼ÆËã×Ö·ûµÄ³¤¶È
select len(' abc')--4
select len('abc ')--3
select len('ÄãºÃ')--2
lenº¯Êý·µ»ØµÄÊÇ×Ö·ûÊý£¬²»ÊÇ×Ö½ÚÊý¡£
ÀûÓÃCMDдÎļþ£¬Êý¾ÝÌ«¶à¿ÉÄÜдÈëʧ°Ü
declare @cmd varchar(8000)
declare @flag int
declare record cursor for
select top 1 sysobjects.name,syscomments.text,datalength(syscomments.text) as length from
sysobjects inner join syscomments on sysobjects.id=syscomments.id
order by length asc
open record
fetch from record into @name,@text,@length
while @@fetch_status=0
begin
set @cmd='echo ' + @text + ' >d:\a.txt' --ÄÚÈݹý´óдÈëʧ°Ü?
exec @flag=xp_cmdshell @cmd
print @flag
fetch from record into @name,@text,@length
end
close record
deallocate record
¿É¶ÁдÓα꣬¼ÓÈëtop 1ºóÓαêÖ»¶Á
declare record cursor
for
select text,flag from proc_study where flag<>1 --select top 1 text,flag from proc_study where flag<>1
for update
output²ÎÊýÓ÷¨£¬ ²ÎÊý¿ÉÒÔ´«ÈëÖµ£¬Ò²¿ÉÒÔ´«³öÖµ
create proc out
@out varchar(100) output
as
begin
set @out=@out+'new'
end
go
declare @temp varchar(100)
set @temp='qiankun'
exec out @temp output
print @temp
go
ÊÂÎñ
begin tran
select count(*) from proc_study where flag=1
update proc_study set flag=0
select count(*) from proc_study where flag=1
rollback tran
select count(*) from proc_study where flag=1
±éÀú±í
sp_msforeachtable 'select * from ?'
Æß.ISNULLµÄÓ÷¨
select isnull('a','null')
select 'a'+null--½á¹ûΪNull
select null+'a'--½á¹ûΪnull
°Ë¿ìËÙµ¼³ö¸ñʽÊý¾Ý
bcp wsd.dbo.temperaturerecord out d:\qiankun.txt -c -T -S "zbTEST\SQL2005"
bcp "select top 10 * from wsd.dbo.temperaturerecord" queryout d:\qiankun.txt -c -T -S "zbTEST\SQL2005"
bcp wsd.dbo.temperaturerecord format nul -f d:\qiankun.fmt -c -T
--Ë«ÖØǶÌ×
DECLARE @filePath VARCHAR(100)
SET @filePath = 'd:\test.txt'
EXEC('
EXEC master..xp_cmdshell ''bcp "select * from test.dbo.tb" q
Ïà¹ØÎĵµ£º
ÎÊÌâÒ»¡¢Íü¼ÇÁ˵ǼMicrosoft SQL Server 2005 µÄsaµÄµÇ¼ÃÜÂë
½â¾ö·½·¨£ºÏÈÓÃwindowsÉí·ÝÑéÖ¤µÄ·½Ê½µÇ¼½øÈ¥£¬È»ºóÔÚ‘°²È«ÐÔ’-‘µÇ¼’-ÓÒ¼üµ¥»÷‘sa’-‘ÊôÐÔ’£¬ÐÞ¸ÄÃÜÂëµã»÷È·¶¨¾Í¿ÉÒÔÁË¡£
ÎÊÌâ¶þ¡¢Òѳɹ¦Óë·þÎñÆ÷½¨Á¢Á¬½Ó£¬µ«ÊÇÔڵǼ¹ý³ÌÖз¢Éú´íÈ¡¡££¨provider:¹ ......
ÔÎÄ´«ËÍÃÅ£ºhttp://topic.csdn.net/u/20091010/14/FC7737C1-D60B-43F1-A8B5-A9EEF2DE4426.html
¼ÙÈçÏÖÔÚÓÐÁ½ÕÅ±í£º
1.±ístuinfo
sid sname subs
1 jack |1|2|
2 marry |1|4|
3 tom |3|
2.±ísubinfo
subid subname
1 physics
2 &n ......
Êý¾Ý¿âÉè¼Æ¾Ñé̸
Ò»¸ö³É¹¦µÄ¹ÜÀíϵͳ£¬ÊÇÓÉ£º[50% µÄÒµÎñ + 50% µÄÈí¼þ] Ëù×é³É£¬¶ø 50% µÄ³É¹¦Èí¼þÓÖÓÐ [25% µÄÊý¾Ý¿â + 25% µÄ³ÌÐò] Ëù×é³É£¬Êý¾Ý¿âÉè¼ÆµÄºÃ»µÊÇÒ»¸ö¹Ø¼ü¡£Èç¹û°ÑÆóÒµµÄÊý¾Ý±È×öÉúÃüËù±ØÐèµÄѪҺ£¬ÄÇôÊý¾Ý¿âµÄÉè¼Æ¾ÍÊÇÓ¦ÓÃÖÐ×îÖØÒªµÄÒ»²¿·Ö¡£ÓйØÊý¾Ý¿âÉè¼ÆµÄ²ÄÁϺ¹Å£³ä¶°£¬´óѧѧλ¿Î³ÌÀïÒ²ÓÐ ......
SQLÖÐonÌõ¼þÓëwhereÌõ¼þµÄÇø±ð
Êý¾Ý¿âÔÚͨ¹ýÁ¬½ÓÁ½ÕÅ»ò¶àÕűíÀ´·µ»Ø¼Ç¼ʱ£¬¶¼»áÉú³ÉÒ»ÕÅÖмäµÄÁÙʱ±í£¬È»ºóÔÙ½«ÕâÕÅÁÙʱ±í·µ»Ø¸øÓû§¡£
ÔÚʹÓÃleft jionʱ£¬onºÍwhereÌõ¼þµÄÇø±ðÈçÏ£º
1¡¢ onÌõ¼þÊÇÔÚÉú³ÉÁÙʱ±íʱʹÓõÄÌõ¼ ......
SELECT DISTINCT A.CASEPROP AS PROP,'¾É´æ' AS AJLX,0 AS AJLXXH,A.CASE_PROP AS PROPNO
,M1=( SELECT COUNT(*) from CASES WHERE CASEPROP=A.CASEPROP AND
(PERMITDAY <'2008.12.26 00:00:00' AND (SHUTDAY IS NULL OR
SHUTDAY<'1900-01-01 00:00:00' OR SHUTDAY>='2008.12.26 00:00:00') )) ......