sql ·þÎñÆ÷½ÇÉ« Êý¾Ý¿â½ÇÉ«
sql ·þÎñÆ÷½ÇÉ« Êý¾Ý¿â½ÇÉ«
·þÎñÆ÷½ÇÉ«
ËùÓеķþÎñÆ÷½ÇÉ«¶¼ÊÇ“¹Ì¶¨µÄ”½ÇÉ«£¬²¢ÇÒ£¬´ÓÒ»¿ªÊ¼¾Í´æÔÚÓÚÄÇÀï——×Ô°²×°ÍêSQL ServerµÄÄÇÒ»¿ÌÆð£¬Ä㽫ӵÓеÄËùÓзþÎñÆ÷½ÇÉ«¾ÍÒѾ´æÔÚÁË¡£
½Ç¡¡¡¡É«
ÌØ¡¡¡¡ÐÔ
sysadmin
¸Ã½ÇÉ«Äܹ»Ö´ÐÐSQL ServerÉϵÄÈκβÙ×÷¡£±¾ÖÊÉÏ£¬ÈκξßÓÐÕâÖÖ½ÇÉ«³ÉÔ±Éí·ÝµÄÈ˶¼ÊÇÄǸö·þÎñÆ÷ÉϵÄsa¡£ÕâÖÖ·þÎñÆ÷½ÇÉ«µÄ´´½¨ÎªÎ¢ÈíÌṩÁËijһÌìÈ¥³ýsaµÇ¼µÄÄÜÁ¦——ʵ¼ÊÉÏ£¬Áª»ú´ÔÊé°Ñsa³Æ×÷±¾ÖÊÉÏΪÒÅÁôÎïµÄ¶«Î÷
Öµ
µÃ×¢ÒâµÄÊÇ£¬ÔÚSQL
ServerÉÏ£¬WindowsµÄAdministrators×é±»×Ô¶¯Ó³Éäµ½sysadmin½ÇÉ«ÖС£ÕâÒâζ×Å·þÎñÆ÷µÄAdministrators×é
ÖеÄÈκγÉԱͬʱҲ¾ßÓжÔSQLÊý¾ÝµÄsa¼¶±ðµÄ·ÃÎÊȨÏÞ¡£Èç¹ûÐèÒª£¬Äã¿ÉÒÔ´Ósysadmin½ÇÉ«ÖÐɾ³ýWindowsµÄadministrators
×飬ÒÔÌá¸ß°²È«ÐÔ¡¢·À·¶Â©¶´
serveradmin
¸Ã½ÇÉ«ÄÜÉèÖ÷þÎñÆ÷·¶Î§µÄÅäÖÃÑ¡Ïî»ò¹Ø±Õ·þÎñÆ÷¡£¾¡¹ÜËüÔÚ·¶Î§ÉÏÏ൱ÓÐÏÞ£¬µ«ÊÇ£¬ÓɸýÇÉ«µÄ³ÉÔ±Ëù¿ØÖƵŦÄܶÔÓÚ·þÎñÆ÷µÄÐÔÄÜ»á²úÉú·Ç³£ÖØ´óµÄÓ°Ïì
setupadmin
¸Ã½ÇÉ«½öÏÞÓÚ¹ÜÀíÁ´½Ó·þÎñÆ÷ºÍÆô¶¯¹ý³Ì
securityadmin
¶ÔÓÚרÃÅ´´½¨³öÀ´ÓÃÓÚ¹ÜÀíµÇ¼Ãû¡¢¶ÁÈ¡´íÎóÈÕÖ¾ºÍ´´½¨Êý¾Ý¿âÐí¿ÉȨÏ޵ĵǼÃûÀ´Ëµ£¬¸Ã½ÇÉ«·Ç³£±ãÀû¡£Ôںܶ෽Ã棬¸Ã½ÇÉ«ÊǵäÐ͵Äϵͳ²Ù×÷Ô±½ÇÉ«——ËüÄܹ»´¦Àí¶àÊýµÄÈÕ³£ÊÂÎñ£¬µ«ÊÇ£¬È´²»¾ß±¸Ò»¸öÕæÕýÎÞËù²»Äܵij¬¼¶Óû§ËùÓµÓеÄÄÇÖÖÈ«¾Ö·ÃÎÊ
processadmin
Äܹ»¹ÜÀíSQL ServerÖÐÔËÐеĽø³Ì——±ØÒªµÄ»°£¬¸Ã½ÇÉ«Äܹ»ÖÕÖ¹³¤Ê±¼äÔËÐеĽø³Ì
dbcreator
¸Ã½ÇÉ«½öÏÞÓÚ´´½¨ºÍ¸ü¸ÄÊý¾Ý¿â
diskadmin
¹ÜÀí´ÅÅÌÎļþ£¨Ö¸ÅɸøÁËʲôÎļþ×é¡¢¸½¼ÓºÍ·ÖÀëÊý¾Ý¿â£¬µÈµÈ£©
bulkadmin
¸Ã
½ÇÉ«ÓÐЩ¹ÖÒì¡£Ëü±»Ã÷È·´´½¨³öÀ´£¬ÓÃÓÚÖ´ÐÐBULK INSERTÓï¾äµÄȨÏÞ£¬·ñÔòµÄ»°£¬Ö»ÄÜÓɾßÓÐsysadminȨÏÞµÄÈËÀ´Ö´ÐÐBULK
INSERTÓï¾ä¡£Ì¹°×µØ˵£¬ÎÒ²»Ã÷°×Ϊʲô¸ÃÓï¾ä²»ÄÜÏñÆäËûÊÂÇéÄÇÑùͨ¹ýGRANTÃüÁîÀ´ÊÚÓèȨÏÞ£¬µ«ËüµÄȷûÓС£Òª¼Çס£¬¼´Ê¹°ÑÒ»¸öÓû§¼ÓÈëµ½ÁË
bulkadmin×éÖУ¬Ò²Ö»ÊǸøÁËËûÃÇ·ÃÎÊÄǸöÓï¾äµÄȨÏÞ£¬¶ÔÓÚÔËÐиÃÓï¾äµÄ±í£¬²¢Ã»ÓÐÊÚÓèÓû§·ÃÎÊÄǸö±íµÄȨÏÞ¡£ÕâÒâζ×Ų»½öÐèÒª°ÑÓû§Ìí¼Óµ½
bulkadminÖУ¬¶øÇÒ£¬¶ÔÓÚÏëÒªÓû§ÄÜÔÚÆäÉÏÖ´ÐÐBULK
INSERTµÄ±í£¬»¹ÒªÊÚÓ裨GRANT£©Óû§INSERTÐí¿ÉȨÏÞ¡£´ËÍ⣬¶ÔÓÚ½«ÔÚBULK
INSERTÓï¾äÖÐÒýÓõÄËùÓÐ±í£¬»¹ÒªÈ·±£Óû§ÓµÓÐÕýÈ·µÄµ½ÄÇЩ±íµÄSELECT·ÃÎÊȨÏÞ
¶ÔÓÚÔÚ·þÎñÆ÷Éϳе£¹
Ïà¹ØÎĵµ£º
ÅжÏÊý¾Ý¿âÀàÐÍ
(select count(*) fromsysobjects)>0 //sqlÊý¾Ý¿â
(select count(*) from msysobjects)>0 //accessÊý¾Ý¿â
µÃµ½SqlÓû§Ãû
user>0
Conversion failed when converting the nvarchar value 'dbo' to data type int.
Öع¹SQLÓï¾ä
ÕûÊýÐÍ
(A) ID=49 ID=49 And [ ²éѯÌõ¼þ] £¬¼´Ê ......
ÔÚVisual Studio 2008 ÖÐʹÓÃO/RÉè¼ÆÆ÷£º
µãÌí¼ÓÏîÄ¿£¬Ñ¡Ôñ´´½¨Linq to SQLÏîÄ¿£¬Ê¹Ó÷þÎñÆ÷×ÊÔ´¹ÜÀíÆ÷Á¬½ÓNorthwindÊý¾Ý¿â£¬½«CustomersºÍOrdersÁ½¸ö±íÍϵ½Éè¼Æ½çÃæÉÏ£¬ÏµÍ³»á×Ô¶¯´´½¨app.configºÍNorthwid.designer.cs,Ç°ÕßÊÇÅäÖÃÁ¬½ÓÊý¾Ý¿âµÄÁ¬½Ó×Ö´®£»ºóÕß»áÉú³ÉÒ»¸ö¼Ì³Ð×ÔDataContextµÄÀࣺNorthwindDataContext¡£
......
×¢ÊÍ:Ö»Êʺϵ¥±íµ¥ÁÐÊý¾Ý,
create database test
go
use test
go
create table users
(
:id int identity(1,1) primary key not null,
:name nvarchar(20)
)
go
create proc sp_Inserts
@Names nvarchar(4000)
as
declare @Name nvarchar(20),@ErrorSum int
:set @ErrorSum = 0
:begin tra ......
ͬһ±í¶à×Ö¶ÎͬʱÖظ´¼Ç¼µÄSQL²éѯ¼°´¦ÀíÊý
±ÈÈçÏÖÔÚÓÐÒ»ÈËÔ±±í £¨±íÃû£ºpeosons£©
ÈôÏ뽫ÐÕÃû¡¢Éí·ÝÖ¤ºÅ¡¢×¡Ö·ÕâÈý¸ö×Ö¶ÎÍêÈ«ÏàͬµÄ¼Ç¼²éѯ³öÀ´
select p1.* from persons p1,persons p2 where p1.idp2.id and p1.cardid = p2.cardid and p1.pname = p2.pname and p1.address ......