sqlserverÁ´½Ó·þÎñÆ÷ʹÓ÷½·¨
EXEC sp_addlinkedsrvlogin @rmtsrvname = 'serverontest', @useself = 'false', @locallogin = 'sa', @rmtuser = 'sa', @rmtpassword = 'passwordofsa'
Ìí¼ÓµÇ¼·½Ê½
ÒÔÉÏÁ½¸öÓï¾äÖУ¬@serverΪ·þÎñÆ÷µÄ±ðÃû£¬@datasrcΪҪÁ´½ÓµÄÄ¿±êÊý¾Ý¿âµÄÁ¬½Ó´®£¬@rmtsrvnameΪ±ðÃû,@localloginΪ±¾µØµÇ¼µÄÓû§Ãû£¬@rmtuserºÍ@rmtpasswordΪҪÁ´½ÓµÄÄ¿±êÊý¾Ý¿âµÄµÇ¼Óû§ÃûºÍÃÜÂë
Ìí¼ÓÍêÁ´½Ó·þÎñÆ÷Ö®ºó£¬¿ÉÒÔͨ¹ýselect * from sys.linked_logins ºÍ select * from sys.serversÀ´²é¿´ÒѾÌí¼ÓµÄÁ´½Ó·þÎñÆ÷ºÍµÇ¼½ÇÉ«
Ìí¼ÓÍêÁ´½Ó·þÎñÆ÷ºó£¬Ê¹ÓÃselect * from ±ðÃû.¿âÃû.dbo.±íÃû À´¶ÔÆäÖеÄÊý¾Ý½øÐвéѯ
ɾ³ýÁ´½Ó·þÎñÆ÷µÇ¼ӳÉäºÍÁ´½Ó·þÎñÆ÷µÄ·½·¨£º
¡¡¡¡exec sp_droplinkedsrvlogin 'serverontest' ,'sa'
¡¡¡¡exec sp_dropserver 'serverontest'
Àý×Ó£º
EXEC sp_addlinkedserver 'xiaoming','','MSDASQL',NULL,NULL,'DRIVER={SQL Server};SERVER=172.18.17.65;UID=sa;PWD=vip;'
--½¨Á¢Á´½Ó·þÎñÆ÷µÇ¼ӳÉä
exec sp_addlinkedsrvlogin @rmtsrvname='xiaoming',@useself='false',@locallogin='sa',@rmtuser='sa',@rmtpassword='vip'
go
¡¡¡¡--²éѯÊý¾Ý
select * from xiaoming.HR_QustionNew.dbo.T_Organise
¡¡¡¡--ɾ³ýÁ´½Ó·þÎñÆ÷µÇ¼ӳÉäºÍÁ´½Ó·þÎñÆ÷:
exec sp_droplinkedsrvlogin 'xiaoming' ,'sa'
exec sp_dropserver 'xiaoming'
¡¡¡¡×¢ÒâÊÂÏî:
¡¡¡¡SET IDENTITY_INSERT [ database.[ owner.] ] { table } { ON | OFF }
¡¡¡¡ËùÒÔ²»ÄÜͨ¹ýÁ¬½Ó·þÎñÆ÷ÉèÖôËÊôÐÔ
¡¡¡¡into Ò²´æÔÚÕâÑùµÄÎÊÌâ
¡¡¡¡select * into xiaoming.northwind.dbo.tt from
¡¡¡¡xiaoming.northwind.dbo.tt
Ïà¹ØÎĵµ£º
1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á ......
ÓÉÓÚ¹¤×÷ÐèÇó£¬Òª¶Ô¸ºÔðµÄ²ú Æ·×öµãÐÔÄÜÓÅ»¯£¬ÔÚÍøÉÏÕÒµ½ÁËÏà¹ØµÄ¶«Î÷£¬Äà ³öÀ´Óë´ó¼Ò·ÖÏí£º
¿´µ½ºÜ¶àÅóÓѶÔÊý¾Ý¿âµÄÀí½â¡¢ÈÏʶ»¹ÊÇûÓÐÍ»ÆÆÒ»¸öÆ¿¾±£¬¶øÕâ¸öÆ¿¾±ÍùÍùÖ»ÊÇÒ»²ã´°Ö½£¬Ô½¹ýÁËÄ㽫¿´µ½Ò»¸öÐÂÊÀ½ç¡£
04¡¢05Äê×öÏîÄ¿µÄʱºò£¬ÓÃSQL Server 2000£¬ºËÐÄ±í£¨´ó²¿·ÖʹÓÃƵ·±µÄ¹Ø¼ü¹¦ÄÜÿ´Î¶¼ÒªÓõ½£©´ïµ½ÁË800ÍòÊý¾Ý ......
ÈçºÎ²é¿´SQL SERVERÊý¾Ý¿âµ±Ç°Á¬½ÓÊý
1.ͨ¹ý¹ÜÀí¹¤¾ß
¿ªÊ¼->¹ÜÀí¹¤¾ß->ÐÔÄÜ£¨»òÕßÊÇÔËÐÐÀïÃæÊäÈë mmc£©È»ºóͨ¹ýÌí¼Ó¼ÆÊýÆ÷Ìí¼Ó SQL µÄ³£ÓÃͳ¼Æ È»ºóÔÚÏÂÃæÁгöµÄÏîÄ¿ÀïÃæÑ¡ÔñÓû§Á¬½Ó¾Í¿ÉÒÔʱʱ²éѯµ½Êý¾Ý¿âµÄÁ¬½ÓÊýÁË¡£²»¹ý´Ë·½·¨µÄ»°ÐèÒªÓзÃÎÊÄÇ̨¼ÆËã»úµÄȨÏÞ£¬¾ÍÊÇҪͨ¹ýWindowsÕË»§µÇ½½øÈ¥²Å¿ÉÒÔÌí¼Ó´Ë¼ÆÊ ......
1.Èç¹ûÏÈprepare ºóÌí¼Ó²ÎÊý£¬ÕâÑùÒ»²¿·ÖÊý¾ÝÀàÐÍ¿ÉÒÔ²»ÓÃÉèÖÃÆäsize´óС£¬ÀýÈçchar
2.Èç¹ûÏÈÌí¼Ó²ÎÊýÔÙprepare£¬¾Í±ØÐëÉèÖòÎÊýµÄÀàÐÍ£¬´óС£¬¾«¶È²ÅÄÜͨ¹ý£¬±ÈÈçchar,varchar,decimalÀàÐÍ£¬¶øint,floatÓй̶¨×Ö½ÚÀàÐ͵ÄÊý¾ÝÀàÐÍÔò¿É²»ÓÃÉèÖôóС¡£
3.¹ØÓÚSqlServerµÄtimestampÀàÐÍ£º¸ÃÀàÐÍΪSqlServerµÄʱ¼ä´ÁÀàÐÍ£¬´´½ ......