for ACCESS :
update a, b set a.name=b.name1 where a.id=b.id
for SQL Server:
"update a set a.name=b.name1 from a,b where a.id=b.id"
update a set a.status=b.status
from table1 a,table2 b
where a.id1=b.id1
update a inner join b on a.a1=b.b1 set a.a2=b.b2Ìõ¼þ
update table1 set a.status = b.status
from table1 a inner join table2 b
on a.idl = b.idl
http://topic.csdn.net/t/20041013/14/3451961.html
http://www.cnblogs.com/hanguoji/archive/2007/02/01/636723.aspx
......
×î½ü·¢ÏÖÎÒÃǹ«Ë¾µÄASP.NETµÄ´úÂëÓÐÆ´½ÓSQLÓï¾äµÄϰ¹ß£¡ÕâÊǷdz£Î£Ïյġ£ÒÔÏÂÎÒ¾ÙÀý˵Ã÷Ò»ÏÂ
Àý×Ó1£º
statement := "SELECT * from users WHERE name = '" + userName + "'; "
½«Óû§Ãû±äÁ¿(¼´username)ÉèÖÃΪ£º
a' or 't'='t£¬´ËʱÔʼÓï¾ä·¢ÉúÁ˱仯£º
SELECT * from users WHERE name = 'a' OR 't'='t';
Èç¹ûÕâÖÖ´úÂë±»ÓÃÓÚÒ»¸öÈÏÖ¤¹ý³Ì£¬ÄÇôÕâ¸öÀý×Ó¾ÍÄܹ»Ç¿ÆÈÑ¡ÔñÒ»¸öºÏ·¨µÄÓû§Ãû£¬ÒòΪ¸³Öµ't'='tÓÀÔ¶ÊÇÕýÈ·µÄ¡£
Àý×Ó2£º
a'; DROP TABLE users; SELECT * from data WHERE name LIKE '%
Õâ¾Í½«×îÖÕµÄSQLÓï¾ä±ä³ÉÏÂÃæÕâ¸öÑù×Ó£º
SELECT * from users WHERE name = 'a'; DROP TABLE users; SELECT * from DATA WHERE name LIKE '%';
½«»áÔì³ÉÊý¾Ý¿â±í±»É¾³ýµÄÑÏÖØºó¹û¡£
ËùÒÔÇ¿ÁÒ½¨Òé´ó¼ÒÍ£Ö¹SQLÓï¾äÆ´½Ó£¨ÌرðÊÇÍøÕ¾Ó¦Óã©£¬²ÉÓôø²ÎÊý»¯´æ´¢¹ý³Ì¡£
¶ÔÓÚÒѾÍê³ÉµÄASP.NETÍøÕ¾Ó¦Óã¬Éè¼ÆÐ޸ĴúÂëÌ«¶àµÄ£¬¿ÉÒÔ¿¼ÂǼÓÈëÈçÏ´úÂë´¦Àíһϣ¬±ÜÃâ±»ÑÏ֨עÈë¹¥»÷¡£¿ÉÒÔͨ¹ýÔÚGlobal.asax.csÎļþÖÐÌí¼Ó¹ýÂ˹ؼü×ֵķ½·¨À´ÊµÏÖ ·ÀÖ¹ sql ×¢Èë¹¥»÷£¨sql injection£©,´úÂëÈçÏ¡£
/// <summary>
/// µ±ÓÐÊý¾Ýʱ½»Ê±£¬´ ......
½ñÌìºöÈ»ms sql2000µÄÆóÒµ¹ÜÀíÆ÷³ö´í£¬ËÑË÷ÁËÒ»ÏÂÕÒµ½Á˽â¾ö°ì·¨£¬¼Ç¼һÏ£¬·½±ãÈÕºó²éѯ
´íÎóÐÅÏ¢£º
---------------------------
Microsoft Management Console
---------------------------
MMC ²»ÄÜ´ò¿ªÎļþ C:\Program Files\Microsoft SQL Server\80\Tools\BINN\SQL Server Enterprise Manager.MSC¡£
Õâ¿ÉÄÜÊÇÓÉÓÚÎļþ²»´æÔÚ£¬²»ÊÇÒ»¸ö MMC ¿ØÖÆÌ¨£¬»òÕßÓúóÀ´°æ±¾µÄ MMC ´´½¨¡£Ò²¿ÉÄÜÊÇÓÉÓÚÄúûÓзÃÎÊ´ËÎļþµÄ×㹻ȨÏÞ¡£
---------------------------
È·¶¨
---------------------------
½â¾ö°ì·¨£º
´ò¿ªÔËÐжԻ°¿òÊäÈ룺mmc
1 ¿ØÖÆÌ¨--Ìí¼Ó/ɾ³ý¹ÜÀíµ¥Ôª--Ìí¼Ó--ÕÒµ½MicrosoftSQLÆóÒµ¹ÜÀíÆ÷--Ìí¼Ó--¹Ø±Õ--È·¶¨
2 ¿ØÖÆÌ¨--Ñ¡Ïî--¿ØÖÆÌ¨Ä£Ê½Ñ¡Ôñ"Óû§Ä£Ê½ÍêÈ«·ÃÎÊ"--½«ÏÂÃæµÄÑ¡ÔñÈ«²¿È¡Ïû
3¿ØÖÆÌ¨--Áí´æÎª--´æ´¢Îª:
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQLServerEnterpriseManager.MSC
×¢£º
Èç¹ûÖ»Êǵ¥»÷¿ì½Ý·½Ê½ºóûÓз´Ó¦¸ÕÖ»ÐèÒªµ½ÉϱßĿ¼ÖÐÕÒµ½SQLServerEnterpriseManager.MSC ÖØÐ´´½¨¿ì½Ý·½Ê½¼´¿É ......
¶ÔSQL Server 2008 ½øÐÐMirrorµÄ»ù±¾ÅäÖü°°²×°¡£
×¼±¸¹¤×÷
1. Principal ÓëMirror ÒÔ¼° Witness Èý̨ʵÀý¶¼°²×°ÎªÏàͬ°æ±¾£¬Ä¿Ç°Êǵ½SQL Server 2008 SP1¡£
2. ÐèÒªÓÐÒ»¸öÓòÕÊ»§·Ö±ðÌí¼Óµ½ Èý̨Êý¾Ý¿âʵÀýËùÔÚµÄServer µÄ Administrators×é¡¢ÒÔ¼°SQL Server Ïà¹ØµÄ×éÖУ» ÓÉÓÚ¾ßÌåµÄ×éµÄ¹¦Äܲ»Çå³þ£¬Òò´Ë½¨ÒéËùÓÐ×é¶¼Ìí¼Ó¸ÃÓòÕÊ»§£¬È·±£È¨ÏÞÔËÐÐÕý³£¡£
3. ½«µÚ¶þ²½ÖеÄÓòÕÊ»§ÉèÖÃΪSQL Server ·þÎñ£¬SQL Server Agent µÄÆô¶¯ÕÊ»§£¬²¢ÖØÆô·þÎñ¡£
4. È·±£Principal ÓëMiroor Á½Ì¨ÊµÀýÉϵÄÊý¾ÝÊý¾Ý¼°ÈÕÖ¾Ïàͬ¡£±¸·ÝģʽΪÍêÈ«±¸·Ý£¬»Ö¸´Ä£Ê½ÎªÍêÈ«£¬ÏòMirrorʵÀýÉϻָ´Êý¾Ý¿âʱ±ØÐëÑ¡ÔñΪNoRecoveryģʽ¡£
´´½¨EndPoint
1. ÔÚPrincipalÓë MirrorʵÀýÉÏ´´½¨EndPoint£¬ÔËÐнű¾£º
Create EndPoint On Principal and Mirror Instance
CREATE ENDPOINT mirroring_ep
STATE=STARTED
AS TCP (LISTENER_PORT=5022)
FOR DATABASE_MIRRORING
(ROLE = PARTNER, ENCRYPTION = SUPPORTED)
--»ò
CREATE ENDPOINT mirroring_ep
STATE=STARTED
AS TCP (LISTENER_PORT=5022)
FOR DATABASE_MIRRORING
(AUTHENTICATION ......
ÔÍøÕ¾ÎÞ·¨·ÃÎÊ£¬¹Ê±£Áôgoogle¿ìÕÕ
How things work :
SQL
Select
Statement
Introduction
:
Ever asked your self how things work inside the
SQL
Select
statement? In this article we won’t be talking about how to writeSQL
Select
statement but rather we will be talking about the algorithms and the methodology behind the
Select
statement and how
SQL
decides which
algorithm
it will use to filter out the results and return our expected results.
Selecting an
Algorithm
:
In fact you can’t do so, it is up to the
SQL
Optimizer implementation to determine the selected
algorithm
that best match the query you are going to invoke in order to enhance the query performance or in other words Optimize it, so you don’t have control over selecting the
algorithm
although some
SQL
Optimizer implementations tri ......
SQLλÔËËã
select 2|8 --10
select 2|8|1 --11
select 10&8 --8,°üº¬,10=8+2
select 10&2 --2,°üº¬,10=2+8
select 10&4 --0,²»°üº¬
select 19&16 --16,°üº¬,19=16+2+1
select 19&8 --0,°üº¬,19=16+2+1
select * from SqlBitOperation where FBitTags&4=4
ÔÚȨÏÞÖеÄÓ¦ÓÃ
1¡¢Á½Õűí
£¨1£©¡¢²Ù×÷ÓëȨÏÞ±êÖ¾±í
if exists (select * from sysobjects where id = OBJECT_ID('[RightTags]') and OBJECTPROPERTY(id, 'IsUserTable') = 1)
DROP TABLE [RightTags]
CREATE TABLE [RightTags] (
[Pkid] [int] IDENTITY (1, 1) NOT NULL,
[RightsName] [nvarchar] (50) NOT NULL,
[RightsTag] [int] NOT NULL DEFAULT (0))
ALTER TABLE [RightTags] WITH NOCHECK ADD CONSTRAINT [PK_RightTags] PRIMARY KEY NONCLUSTERED ( [Pkid] )
SET IDENTITY_INSERT [RightTags] ON
INSERT [RightTags] ([Pkid],[RightsName],[RightsTag]) VALU ......