Êý¾Ý¿âÃû£ºEmployee
±íÃû£ºEmployees
uid£ºsa
pwd£ºsa
ÎÊÌâ²¹³ä£º
×îºÃÊÇÌṩSQL SERVER½Ó¿Ú·ÃÎÊÊý¾Ý¿âµÄ´úÂë
Õâ¶Î´úÂëÊÇVS.NET×Ô¶¯Éú³É£¬ÀïÃæÓÐÄÄЩÊDz»ÐèÒªµÄÄØ£¿Ó¦¸Ã°ÑÊý¾Ý¿âÁ¬½ÓµÄ´úÂë·ÅÔÚÄĸöµØ·½ÄØ£¿
<%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm3</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
</form>
</body>
</html>
landy543210 µÄ»Ø´ðÊǶԵģ¬²»¹ýÓÐЩÎÊÌ⣺
1¡¢ºÜÏÔÈ»LZÔÚwebÓ¦ÓóÌÐ ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
¡¡¡¡2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
¡¡¡¡3¡¢ËµÃ÷£º±¸·Ýsql server
¡¡¡¡--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
¡¡¡¡--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
¡¡¡¡4¡¢ËµÃ÷£º´´½¨Ð±í
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
¡¡¡¡¸ù¾ÝÒÑÓÐµÄ±í´´½¨ÐÂ±í£º
A£ºcreate table tab_new like tab_old (ʹÓÃ¾É±í´´½¨Ð±í)
B£ºcreate table tab_new as select col1,col2… from tab_old definition only
¡¡¡¡5¡¢ËµÃ÷£º
¡¡¡¡É¾³ýÐÂ±í£ºdrop table tabname
¡¡¡¡6¡¢ËµÃ÷£º
¡¡¡¡Ôö¼ÓÒ»¸öÁУºAlter table tabname add column col type
¡¡¡¡×¢£ºÁÐÔö¼Óºó½«²»ÄÜɾ³ý¡ ......
--×÷ÓãºÊý¾Ý¿âÖÐµÄ±í±¸·Ý³ÉÎı¾
Declare @tabname varchar(200),@ip varchar(50),@user varchar(50),@password varchar(50),@sql varchar(1000),@filetxt varchar(200),@file varchar(50)
set @tabname='database.dbo.tb' --±íÃû
set @ip='127.0.0.1' --IPµØÖ·£¬±¾»úµÄ»°¾Íд127.0.0.1
set @user='sa' --Êý¾Ý¿âÓû§Ãû
set @password='123' --Êý¾Ý¿âÃÜÂë
set @file='c:\' --±¸·Ý·¾¶
set @filetxt='tb.txt' --±¸·ÝÎļþÃû
set @sql='Bcp '+@tabname+' out '+@file+@filetxt+' -S '+@ip+' -U '+@user+' -P '+@password+' -t \t -c'
Print @sql
Exec master..xp_cmdshell @sql,No_Output ......
ÔÚ¿ª·¢²»ÂÛÊÇWEB»¹ÊÇWinform³ÌÐòÖУ¬Êý¾Ý·ÖÒ³ÊǾ³£Óöµ½µÄÎÊÌ⣬ҪÊÇÔÚ´úÂëÖÐʵÏִ˹ý³Ì£¬ÏÔÈ»½µµÍÁË·þÎñÆ÷µÄЧÂÊ£¬¿ÉÒÔʹÓÃÒÔÏ´洢¹ý³ÌÀ´ÊµÏÖ¡£
CREATE PROCEDURE pagination
@tblName varchar(255), -- ±íÃû
@strGetFields varchar(1000) = '*', -- ÐèÒª·µ»ØµÄÁÐ
@fldName varchar(255)='', -- ÅÅÐòµÄ×Ö¶ÎÃû
@PageSize int = 10, -- Ò³³ß´ç
@PageIndex int = 1, -- Ò³Âë
@doCount bit = 0, -- ·µ»Ø¼Ç¼×ÜÊý, ·Ç 0 ÖµÔò·µ»Ø
@OrderType bit = 0, -- ÉèÖÃÅÅÐòÀàÐÍ, ·Ç 0 ÖµÔò½µÐò
@strWhere varchar(1500) = '' -- ²éѯÌõ¼þ (×¢Òâ: ²»Òª¼Ó where)
AS
declare @strSQL varchar(5000) -- Ö÷Óï¾ä
declare @strTmp varchar(110) -- ÁÙʱ±äÁ¿
declare @strOrder varchar(400) -- ÅÅÐòÀàÐÍ
if @doCount != 0
begin
if @strWhere !=''
set @strSQL = 'select count(*) as Total from [' + @tblName + '] where '+@strWhere
else
set @strSQL = 'select count(*) as Total from [' + @tblName + ']'
end
--ÒÔÉÏ´úÂëµÄÒâ˼ÊÇÈç¹û@doCount´«µÝ¹ýÀ´µÄ²»ÊÇ0£¬¾ÍÖ´ÐÐ×ÜÊýͳ¼Æ¡£ÒÔϵÄËùÓдúÂ붼ÊÇ@doCountΪ0µÄÇé¿ö
e ......
¸ÕÅöµ½Õâ¸öÎÊÌâʱ£¬ÒÔΪÊÇÓ¦Ó÷þÎñÆ÷ºÍÊý¾Ý¿â·þÎñÆ÷ûÁ¬Í¨£¬²éÁË°ëÌìµÄÍøÂç½á¹ûÍøÉÏÒ»²é£¬¸úSQL Server 2005Óйأ¬ÄãÌ«ÑôµÄ£¡
¿ªÊ¼²Ëµ¥-SQLServer2005-ÅäÖù¤¾ß-SQL Server Configuration Manager-SQLserver2005ÍøÂçÅäÖÃ-MSSQLSERVERµÄÐÒé-Ë«»÷TCP/IPÐÒé
°ÑIP¸Ä³Éµ±Ç°Ê¹Óõģ¬µ±È»£¬¶Ë¿ÚҲҪȷ±£ÕýÈ·¡£ÔÙÖØÆôÊý¾Ý¿â£¬¾ÍOKÁË¡£¸ÄÁËIPµØÖ·£¬SQLServer¾ÓÈ»²»»á×Ô¶¯Ð޸ģ¬Õæ´À£¬ÔÙÌ«ÑôÒ»´ÎMS ......
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
{
&nb ......