Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¼òµ¥µÄsqlµÇ¼ºÍ×¢²á´æ´¢¹ý³Ì

 Ê×ÏÈÎÒ½¨ºÃÁËÒ»ÕÅÓû§±í±íÖÐÓÐÁ©¸ö×ֶΠһ¸öÊÇÕ˺ţ¬Ò»¸öÊÇÃÜÂ뵱ȻÕâÀïÎÒдµÄ֪ʶ¼òµ¥µÄµÇ¼ºÜ×¢²á£¬
±íÃ÷ users Óû§±í
×ֶΠaccountnum  varchar(50) --±íʾÕ˺Å
        password     varchar(50) --±íʾÃÜÂë
µÇ¼´æ´¢¹ý³Ì
create proc use_login
(
@accountnum varchar(50),
@password varchar(50),
@message  varchar(50) output

as
  if exists(select * from users where accountnum=@accountnum and  password=@password)
   set @message='µÇ¼³É¹¦'
 else  if  exists(select * from users where accountnum=@accountnum )
   set @message='ÃÜÂë´íÎó'
 else if exists(select * from users where password=@password)
  set @message='Óû§Ãû´íÎó'
else
  set @message='Óû§ÃûºÍÃÜÂ붼´íÎó'
declare @msg as varchar(50)
exec use_login 'text','text',@msg output
print @msg
×¢²á´æ´¢¹ý³Ì
create proc use_registration
(
@accountnum varchar(50),
@password varchar(50),
@message  varchar(50) output
)
as
  if exists(select * from users where accountnum=@accountnum)
   set @message='¸ÃÓû§ÒѾ­´æÔÚ'
 else
    begin
     insert into users values(@accountnum,@password)
     set @message='¹§Ï²Äú£¬¿ÉÒÔ×¢²á¸ÃÓû§'
  end 
  declare  @msg as varchar(50)
 exec use_registration 'text','text',@msg output
print @msg
ÉÏÃæÔÙÖ´Ðд洢¹ý³ÌµÄʱºò Òª´òÓ¡ËùÒªÏÔʾ³öÀ´µÄÐÅÏ¢ÓõÄÊÇprint Ò²¿ÉÒÔÓÃselect
 


Ïà¹ØÎĵµ£º

Mysql µ¼Èë .sqlÎļþÖÐÎÄÂÒÂ룿

 --default-character-set=utf8 ÓëÐÞ¸ÄsqlÎļþ¼ÓÈ룺SET NAMES 'utf8'; 
µ¼Èë½Å±¾Ê±£¬SET NAMES 'xxx' £¬xxxÓ¦¸ÃºÍsql½Å±¾ÎļþµÄʵ¼Ê±àÂëÒ»Ö£¬Èç¹ûÄãÉèÖõÄʱutf-8 £¬ÄÇôÇëÈ·ÈÏÄãµÄsql½Å±¾Îļþʱutf-8±£´æµÄ:
iconv -f UTF-8 xxx.sql
Èç¹ûÏÔʾÕý³££¬ÄÇôÕâÒ»²½¾ÍOKÁË
ÁíÍâ×¢ÒâÄãµÄ½Å±¾ÀÓÐûÓиø¿â±íÉèÖ ......

Ïê½âAsp.Net SqlÊý¾Ý¿âÁ¬½Ó×Ö·û´®


1.Á¬½ÓÊý¾Ý¿âÎļþ
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" />
SqlConnectionStringBuilderʵÀý»¯Ê±£¬ÒªÓõ½connectionString£¬È磺SqlConnectionStringBuild builder = new SqlC ......

¶ÁÈ¡ExcelÊý¾Ýµ½SQLÊý¾Ý¿â

±¾ÎÄʵÏÖÔÚc#ÖпɸßЧµÄ½«excelÊý¾Ýµ¼Èëµ½sqlserverÊý¾Ý¿âÖÐ,ºÜ¶àÈËͨ¹ýÑ­»·À´Æ´½Ósql£¬ÕâÑù×ö²»µ«ÈÝÒ׳ö´í¶øÇÒЧÂʵÍÏ£¬×îºÃµÄ°ì·¨ÊÇʹÓÃbcp£¬Ò²¾ÍÊÇSystem.Data.SqlClient.SqlBulkCopy ÀàÀ´ÊµÏÖ¡£²»µ«Ëٶȿ죬¶øÇÒ´úÂë¼òµ¥£¬ÏÂÃæ²âÊÔ´úÂëµ¼ÈëÒ»¸ö6Íò¶àÌõÊý¾ÝµÄsheet£¬°üÀ¨¶ÁÈ¡£¨È«²¿¶ÁÈ¡±È½ÏÂý£©ÔÚÎҵĿª·¢»·¾³ÖÐÖ»ÐèÒª1 ......

caseÓï¾äÔÚSQLÖеÄʹÓ÷½·¨

Case¾ßÓÐÁ½ÖÖ¸ñʽ¡£¼òµ¥Caseº¯ÊýºÍCaseËÑË÷º¯Êý¡£
--¼òµ¥Caseº¯Êý
CASE sex
WHEN '1' THEN 'ÄÐ'
WHEN '2' THEN 'Å®'
ELSE 'ÆäËû' END
--CaseËÑË÷º¯Êý
CASE WHEN sex = '1' THEN 'ÄÐ'
WHEN sex = '2' THEN 'Å®'
ELSE 'ÆäËû' END
ÕâÁ½ÖÖ·½Ê½£¬¿ÉÒÔʵÏÖÏàͬµÄ¹¦ÄÜ¡£¼òµ¥Caseº¯ÊýµÄд·¨Ïà ......

ÔõÑù²ÅÄÜʵÏÖÅÅÐòÓÅ»¯µÄ²ã´Î¹Øϵ±íÉè¼Æ_SQL¼¼ÇÉ

 Êý¾Ý²ã´ÎµÄ¸ÅÄî:
Êý¾Ý²ã´ÎÊDZí´ïÊý¾ÝµÄÒ»ÖÖÖØÒª¹Øϵ£¬ÔÚÊý¾Ý¿âµÄÉè¼ÆÖУ¬È磺×éÖ¯½á¹¹·Ö½â¡¢¹¤×÷ÈÎÎñ·Ö½â¡¢ÐÐÕþÇø»®µÄ·Ö½âµÈ¶¼ÊDzã´Î¹ØϵÊý¾ÝµÄµäÐÍʵÀý¡£
±í´ï²ã´Î¹ØϵµÄÊý¾ÝÒ»°ãÐèҪʵÏÖÈçÏÂÊôÐÔ£º

 
1.²ã´ÎµÄ×î´ó¼¶Áª²ã´ÎÊý¡£È磺Öйú£­>ºþÄÏÊ¡->³¤É³ÊÐ->Ó껨Çø£¬¾ÍÊÇ4²ã¡£
2.ÄÜ·´Ó³Í¬Ò»² ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ