.NET »ñÈ¡¾ÖÓòÍøµÄsql server Áбí
SqlDataSourceEnumerator instance =SqlDataSourceEnumerator.Instance;
System.Data.DataTable table = instance.GetDataSources();
»ò
System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources();
·µ»ØDatatable
´Ëtable°üº¬ÒÔÏÂËĸö×Ö¶Î
Console.WriteLine("·þÎñÆ÷Ãû = {0}", row["ServerName"]);
Console.WriteLine("ʵÀýÃû = {0}", row["InstanceName"]);
Console.WriteLine("ÊÇ·ñ¼¯³ÉÑéÖ¤ = {0}", row["IsClustered"]);//¼´WindowsÉí·ÝÑéÖ¤ºÍSQL ServerÑéÖ¤
Console.WriteLine("°æ±¾ = {0}", row["Version"]);//8.*ÊÇSQL 2000,9.*ÊÇSQL 2005
·½·¨Ò»£ºÍ¨¹ýMicrosoft.SQLDMO.Object×é¼þ¾Í¿ÉÒÔÇáËÉÍê³É´ËÏ×÷£º
Ê×ÏÈÈçºÎÕÒµ½Microsoft.SQLDMO.Object
1.ÈçºÎÔÚÄúµÃÏîÄ¿ÖÐÄܹ»Ê¹ÓÃSQLDMO×é¼þ£¿
²Ëµ¥£ÏîÄ¿£Ìí¼ÓÒýÓãCOM-Microsoft.SQLDMO.Object
2.½«¸Ã¹¦ÄÜд³ÉÒ»¸öÀࣺ
using System;
using System.Collections;
using System.Collections.Specialized;
namespace JillZhang
{
/**//// <summary>
/// Summary description for SqlInfo.
/// </summary>
public class SqlInfo
{
³ÉÔ±±äÁ¿#region ³ÉÔ±±äÁ¿
private string _uid="";
private string _pwd="";
private StringCollection _serverList=new StringCollection();
private Hashtable _databaseList=new Hashtable();
#endregion
¹¹Ô캯Êý#region ¹¹Ô캯Êý
public SqlInfo()
{
this._serverList=GetSqlInstances();
&nb
Ïà¹ØÎĵµ£º
ÎÞ·¨´ò¿ªÓû§Ä¬ÈÏÊý¾Ý¿â£¬µÇ¼ʧ°Ü,ÕâÊÇSQL ServerʹÓÃÕßÊìϤµÄÎÊÌâÖ®Ò»¡£ÔÚʹÓÃÆóÒµ¹ÜÀíÆ÷¡¢²éѯ·ÖÎöÆ÷¡¢¸÷À๤¾ßºÍÓ¦ÓÃÈí¼þµÄʱºò£¬Ö»Òª¹Øϵµ½Á¬½ÓSQL ServerÊý¾Ý¿âµÄʱºò£¬¶¼ÓпÉÄÜ»áÅöµ½´ËÎÊÌâ,ÒýÆð´Ë´íÎó·¢ÉúµÄÔÒò±È½Ï¶à,ÏÂÃæÎÒÃǾÍÀ´Ïêϸ·ÖÎöÒýÆð´ËÎÊÌâµÄÔÒòÒÔ¼°½â¾ö°ì·¨¡£
Ò»¡¢ÔÒò
µÇ¼ÕÊ»§µÄĬÈÏÊý¾Ý¿â±»É¾³ý¡ ......
1. ²é¿´Êý¾Ý¿âµÄ°æ±¾
¡¡¡¡ select @@version
¡¡¡¡2. ²é¿´Êý¾Ý¿âËùÔÚ»úÆ÷²Ù×÷ϵͳ²ÎÊý
¡¡¡¡exec master..xp_msver
¡¡¡¡3. ²é¿´Êý¾Ý¿âÆô¶¯µÄ²ÎÊý
¡¡¡¡sp_configure
¡¡¡¡4 ......
Éí·ÝÖ¤ÑéÖ¤Ëã·¨(SQL°æ)
/**//*
ÑéÖ¤Éí·ÝÖ¤Ëã·¨
By:Áõ־ΰ
2008-1-29ÓëÌì½ò
*/
CREATE FUNCTION [fn_ValidateIDC]
(
@idc varchar(18)
)RETURNS BIT
AS
BEGIN
IF LEN(@idc)<>15 AND LEN(@idc)<>18--Éí·ÝÖ¤ºÅÖ»ÓÐ15»ò18λ
RETURN(0)
IF LEN(@idc)=15 --Èç¹ûÊÇ15λÉí·ÝÖ¤ ÔòÖ»ÑéÖ¤ÈÕÆÚºÍÊÇ·ñ ......
Ò»¡¢¼òµ¥ÊµÓõı¸·Ý·½·¨£º
ÆóÒµ¹ÜÀíÆ÷ÖеÄTools£¬Database Maintenance Planner£¬¿ÉÒÔÉèÖÃÊý¾Ý¿âµÄ¶¨ÆÚ×Ô¶¯±¸·Ý¼Æ»®¡£²¢Í¨¹ýÆô¶¯Sql server AgentÀ´×Ô¶¯ÔËÐб¸·Ý¼Æ»®¡£¾ßÌå²½ÖèÈçÏÂ:
1¡¢´ò¿ªÆóÒµ¹ÜÀíÆ÷£¬ÔÚ¿ØÖÆ̨¸ùĿ¼ÖÐÒÀ´Îµã¿ªMicrosoft SQL Server-->SQL Server×é-->Ë«»÷´ò¿ªÄãµÄ·þÎñÆ÷
2¡¢È»ºóµãÉÏÃæ²Ëµ¥ÖÐ ......
sqlÊý¾ÝÀàÐÍÏê½â
(1)¶þ½øÖÆÊý¾ÝÀàÐÍ
¡¡¡¡¶þ½øÖÆÊý¾Ý°üÀ¨ Binary¡¢Varbinary ºÍ Image
¡¡¡¡Binary Êý¾ÝÀàÐͼȿÉÒÔÊǹ̶¨³¤¶ÈµÄ(Binary),Ò²¿ÉÒÔÊDZ䳤¶ÈµÄ¡£
¡¡¡¡Binary[(n)] ÊÇ n λ¹Ì¶¨µÄ¶þ½øÖÆÊý¾Ý¡£ÆäÖУ¬n µÄÈ¡Öµ·¶Î§ÊÇ´Ó 1 µ½ 8000¡£Æä´æ´¢ñ¿µÄ´óСÊÇ n + 4 ¸ö×Ö½Ú¡£
¡¡¡¡Varbinary[(n)] ÊÇ n λ±ä³¤¶ÈµÄ¶þ½øÖÆÊ ......