´¥·¢Æ÷»ñÈ¡Ð޸ıíµÄSQLÓï¾ä
/*
´¥·¢Æ÷»ñÈ¡SQLÓï¾äÔöÁ¿´«Êä
¹¦ÄÜ£º²¶×½Ð޸ıíµÄSQLÓï¾ä
ʹÓÃ˵Ã÷£º 1¡¢ÏÈн¨Ò»±íÊÖ¶¯Ð´ÈëÖ÷¼üÐÅÏ¢»òÕßΨһË÷Òý
Create table prmary_key
(tab_name varchar(255),
key_name varchar(255))
--´Ë±í½öÔÚ½¨Á¢´¥·¢Æ÷ʱʹÓ㬽¨ÍêËùÓд¥·¢Æ÷ºó ¼ÇµÃɾ³ý
2¡¢½¨´¥·¢Æ÷½öÐèÒªÐÞ¸Ä@tab_name±äÁ¿£¬¼´¿É
Create By Yujiang
*/
Declare @cursql varchar(8000),
@cursqltmp varchar(8000),
@curkey Varchar(500), --Ö÷¼ü»òΨһË÷Òý
@curkeytmp Varchar(2000), --Ö÷¼üÑ»·ÓÃ
@curkeywhere Varchar(1000), --Ö÷¼üÌõ¼þ
@curkeyjoin Varchar(1000), --¹ØÁªÌõ¼þ
@curexecsql varchar(5000), --Ö´ÐÐSQL
@curcols varchar(2000), --ËùÓеÄÁÐÃû
@curcolstmp varchar(2000), --Ñ»·ÓÃ
@tab_name varchar(255),
@curtmp varchar(255), --Ñ»·ÓÃ
@curcoltype varchar(255) --×Ö¶ÎÊý¾ÝÀàÐÍ
Set @tab_name = 'tj_suggestion' --¡ïÐèÒªÊÖ¶¯ÐÞ¸Ä
Select @cursql = ' if exists(select * from sysobjects where name = '+ char(39) + 'tr_' + @tab_name +'_ZLYJ' + char(39) + ' and type = ''TR'')'
+ char(13) + char(10)
+ ' drop trigger tr_'+ @tab_name + '_ZLYJ'
Exec(@cursql)
--»ñÈ¡Ö÷¼ü
Select @curkey = key_name from prmary_key where tab_name = @tab_name
if (@curkey is Null or @curkey = '')
Begin
Print @tab_name + 'ûÓÐÖ÷¼ü»òΨһË÷ÒýÎÞ·¨²¶×½SQLÓï¾ä'
Return
End
Set @curcols = ''
Set @cursqltmp = ''
if right(@curkey,1) <> ','
Set @curkey = @curkey + ','
declare @col_name varchar(50)
Declare #tmp_cur cursor
for select name from syscolumns where id = object_id(@tab_name)
open #tmp_cur
fetch next from #tmp_cur into @col_name
while @@fetch_status = 0
&nbs
Ïà¹ØÎĵµ£º
ÔÚÇÚÕÜEXCEL·þÎñÆ÷ÖÐÓÐ×óÓÒÄÚÁ¬½ÓµÄ²Ù×÷£¬ÎÒÃÇÔÚÕâÀïÓÃSQLÓï¾äÀ´Êµ¼Ê˵Ã÷Ò»ÏÂÖ®¼äµÄÇø±ðÓë×÷Óá£
= ÄÚÁ¬½Ó SQLÖÐΪinner join
*= ×óÁ¬½Ó °üº¬ËùÓеÄ×ó±ß±íÖеļǼÉõÖÁÊÇÓұ߱íÖÐûÓкÍËüÆ¥ÅäµÄ¼Ç¼¡£ SQLÖÐΪleft j ......
SQL ServerµÄ¸´ºÏË÷Òýѧϰ
¸ÅÒª
ʲôÊǵ¥Ò»Ë÷Òý,ʲôÓÖÊǸ´ºÏË÷ÒýÄØ? ºÎʱн¨¸´ºÏË÷Òý£¬¸´ºÏË÷ÒýÓÖÐèҪעÒâЩʲôÄØ£¿±¾ÆªÎÄÕÂÖ÷ÒªÊǶÔÍøÉÏһЩÌÖÂÛµÄ×ܽᡣ
Ò».¸ÅÄî
µ¥Ò»Ë÷ÒýÊÇÖ¸Ë÷ÒýÁÐΪһÁеÄÇé¿ö,¼´Ð½¨Ë÷ÒýµÄÓï¾äֻʵʩÔÚÒ»ÁÐÉÏ¡£
Óû§¿ÉÒÔÔÚ¶à¸öÁÐÉϽ¨Á¢Ë÷Òý£¬ÕâÖÖË÷Òý½Ð×ö¸´ºÏË÷Òý(×éºÏË÷Òý)¡£¸´ºÏË÷ÒýµÄ´´½¨· ......
SQL Server .NET Data Provider Á¬½Ó×Ö·û´®°üº¬Ò»¸öÓÉһЩÊôÐÔÃû/Öµ¶Ô×é³ÉµÄ¼¯ºÏ¡£Ã¿Ò»¸öÊôÐÔ/Öµ¶Ô¶¼ÓɷֺŸô¿ª¡£
PropertyName1=Value1;PropertyName2=Value2;PropertyName3=Value3;.....
ͬÑù£¬Á¬½Ó×Ö·û´®±ØÐë°üº¬SQL ServerʵÀýÃû³Æ:
  ......
Èç¹ûÏë²éÕÒ“_cs”½áβµÄµÄÕË»§
select * from [user] where loginname like '%_cs'ÊDz»Ðеģ¬_ ±»ÈÏΪÊÇÈÎÒâµÄ×Ö·û£¬
ËùÒÔÐèҪתÒå×Ö·û£¬ÓÐÁ½ÖÖд·¨£º
select * from [user] where loginname like '%[_]cs'
select * from [user] where loginname like '%/_cs' escape'/'
ͨÅä·ûº¬Òå
%
°üº¬Áã¸ö»ò¸ü¶à×Ö· ......
µ±SQL Server½Ø¶ÏÊÂÎñÈÕ־ʱ£¬Ëü½ö½öÊÇÔÚÐéÄâÈÕÖ¾ÎļþÖÐ×ö¸ö±ê¼Ç£¬ÒԱ㲻ÔÙʹÓÃËü£¬È»ºó×¼±¸ÒÔÖØÓÃÐÎʽÀ´×ö±¸·Ý(¼ÙÈçÔËÔØÔÚÍêÕû»òÊÇÅúÁ¿ÈÕÖ¾»Ö¸´Ä£ÐÍ)¡£Ò²¾ÍÊÇ˵£¬ÔÚʹÓüòµ¥»Ö¸´Ä£ÐÍʱ£¬ÊÂÎñÈÕÖ¾°üÀ¨ÈçϵÄÈÕÖ¾¼Ç¼£º
µ±checkpoint·¢Éúʱ£¬ÐéÄâÈÕÖ¾Îļþ1¡¢2²»ÔÙ±»Ê¹Óã¬ÒòΪÊÂÎñ1¡¢2ÒѾ±»Ìá½»ÁË£¬¶øÇÒÈÕÖ¾¼Ç¼Ҳ²»ÔÙÐ ......