SqlServer´¥·¢Æ÷Àí½â
´¥·¢Æ÷µÄ¶¨ÒåÓë·ÖÀà:
Ö»Òª´¥·¢Æ÷ËùÔÚ±íÉϵĶÔӦʱ¼ä·¢Éú,¾Í»á×Ô¶¯Ö´Ðиô¥·¢Æ÷µÄ´úÂë.ʵ¼ÊÉÏ,ÎÒÃDz¢²»ÄÜÖ±½Óµ÷Óô¥·¢Æ÷,ΨһµÄ·½·¨ÊÇÔÚ·ÖÅäŶ´¥·¢Æ÷µÄ±íÉÏÖ´ÐÐijÖÖÐÐΪ·½¿É¼¤»î´¥·¢Æ÷. [´¥·¢Æ÷ÊÇÒ»ÖÖÌØÊâµÄ´æ´¢¹ý³Ì,ËûÔÚÖ´ÐÐÌض¨µÄÓïÑÔʼþʱÉúЧ
SQL Server°üÀ¨Á½´óÀà´¥·¢Æ÷:DDL(Êý¾Ý¶¨ÒåÓïÑÔ)´¥·¢Æ÷ºÍDML(Êý¾Ý²Ù×÷ÓïÑÔ)´¥·¢Æ÷
DDL´¥·¢Æ÷:
µ±·þÎñÆ÷»òÊý¾Ý¿âÖз¢ÉúÊý¾Ý¶¨ÒåÓïÑÔ(DDL)ʱ,½«µ÷ÓÃÕâЩ´¥·¢Æ÷.DDL´¥·¢Æ÷ÊÇÒ»ÖÖÌØÊâµÄ´¥·¢Æ÷,ÔÚÓ°ÏìÊý¾Ý¶¨ÒåÓïÑÔÓï¾äʱ³ö·¢,¿ÉÒÔÓÃÓÚÔÚÊý¾ÝÖÐÖ´ÐйÜÀíÈÎÎñ,ÀýÈçÉóºËÒÔ¼°¹æ·¶Êý¾Ý¿âÖеIJÙ×÷.
ÀýÈç:Drop table,Create table
Àý1:
create trigger tr_1
on database
for Create_Table --|| Drop_Table
as
raiserror('Äã²»ÄÜ´´½¨±í',16,1)
rollback --¿ÉÒÔ½øÐлعöÒòΪCreate_table ÊÇÒþʽÊÂÎñ
drop trigger tr_1 on database –-ɾ³ý´¥·¢Æ÷ʱ±ØÐëÓÐon databaseÖ¸Ã÷ÊÇɾ³ýÊý¾Ý¿âÉϵĴ¥·¢Æ÷
DML´¥·¢Æ÷:
µ±Êý¾Ý¿â²Ù×÷Öз¢ÉúÊý¾Ý²Ù×÷ÓïÑÔ(DML)ʼþʱ,½«µ÷ÓÃDML´¥·¢Æ÷.
DML´¥·¢Æ÷¿ÉÒÔ·ÖΪÒÔÏÂ3ÖÖÀàÐÍ:
1.AFTER ´¥·¢Æ÷:AFTER ´¥·¢Æ÷Ö»ÄÜÔÚ±íÉÏÖ¸¶¨ (ºó´¥·¢)
ÔÚÖ´ÐÐInsert Update Delete Óï¾ä²Ù×÷Ö®ºóÖ´ÐÐ AFTER ´¥·¢Æ÷,Öƶ¨AFTERÓëÖƶ
Ïà¹ØÎĵµ£º
SQLServer CodeSmith C#
bigint Int64   ......
SQLSERVER 2000
ÿ´Î´ò¿ªSQLServer²éѯ·ÖÎöÆ÷ºó£¬ÔÚÁ¬½Ó´°¿ÚÀïµÄSQLServer·þÎñÆ÷Ñ¡ÔñÏÂÀ¿òºÍµÇ¼Óû§ÃûÊäÈë¿òÀﶼ»áÁôÓÐÀúÊ·µÇ¼µÄ¼Ç¼£¬ÓÐʱºòÎÒÃÇÊDz»Ï£ÍûÕâÑùµÄ£¬±ÈÈçÔÚÒ»¸ö·Ç˽ÓÐÁìµØ×öÁËÔÝʱµÄ¿ª·¢ºó£¬²»ÏëÁôÏÂÈκÎÁ¬½ÓÔ¶³ÌÊý¾Ý¿âµÄ¼Ç¼£¬ÈçºÎɾ³ýÄØ£¿»¹ÊÇ×¢²á±í£¬ÕÒµ½ÒÔÏ·¾¶£º
HKEY_CURRENT_USER\Software\Micr ......
ÉÏ´Î×öÁ˸öÏîÄ¿£¬Éæ¼°µ½Êý¾Ý¿âµÄ»¹ÔºÍ»Ö¸´£¬µ½ÍøÉÏÕÒÁËһϣ¬ÊÇÀûÓÃSQLDMOʵÏֵģ¬Ö»ÒªÌí¼ÓSQLDMOÒýÓþͺÃÁË£¬
È»ºóÀûÓÃϱߵÄÀàµÄ·½·¨¾Í¿ÉÒÔʵÏÖÁË¡£
ÎÒ°ÑÔ×÷ÕßµÄÀàÀ©³äÁËһϣ¬¿ÉÒÔ×Ô¶¯Ê¶±ðweb.configÀï µÄÊý¾Ý¿âÁ¬½Ó×Ö·û´®£¬¿ÉÒÔͨ¹ý±äÁ¿ÉèÖû¹Ô»Ö¸´µÄÐÅÏ¢¡£
ÐèҪעÒâµÄʱ»¹Ô£¬»¹ÔµÄʱºòÎÊÌâ ......
/*
*SQLServerÌí¼Ó²Ù×÷ʵÏÖ
*/
void CMFCSQLDlg::OnButton2()
{
// TODO: Add your control notification handler code here
CString strsql;
CString strnum="mynum3";
CString strage="myage3";
HRESULT hResult;
_variant_t RecordsAffected;
CoInitialize(NULL);
_ConnectionPtr m_pAppConn;
hResul ......
Ñ¡ÔñÖ¸¶¨ÌõÊýÓï¾ä£º
db2£ºselect * from tabname fetch frist n rows only
informix£ºselect first n *
from tabname
oralce£ºselect * from tabname where rownum <= n
sql server :select top n * from tabname ......