Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

EXCELÉú³ÉSQL½¨±í´æ´¢¹ý³ÌµÄVBA½Å±¾

HO~HO~EXCELÉú³ÉSQL½¨±í´æ´¢¹ý³ÌµÄVBA½Å±¾^_^ÔÞÒ»ÏÂ
2007-12-11 10:39
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ È«¾Ö±äÁ¿¶¨Òå
Const MAX_COLUMN_NUM = 50
Dim stOutputPath As String
Dim stOutputFile As String
Dim stDBName As String
Dim stUserName As String
Dim stUserPasswd As String
   
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Set InitProcess³õʼ»¯¹ý³Ì
Public Sub InitProcess()
    '³õʼ»¯Êä³öÎļþ¼Ð
    stOutputPath = Application.ThisWorkbook.Path + "\OUTSQL\"
    '³õʼ»¯Êý¾Ý¿âÃû
    stDBName = Worksheets("Ê×Ò³").Cells(1, 2).Value
    If stDBName = "" Then
        MsgBox "Êý¾Ý¿âÃû²»ÄÜΪ¿Õ"
        Exit Sub
    End If
   
    '³õʼ»¯Êä³öÎļþÃû
    stOutputFile = stOutputPath & stDBName & "Create.sql"
   
   
    '´´½¨Êä³öÎļþ¼ÐandÎļþ
    On Error Resume Next
    If Dir(stOutputPath) = "" Then
        MkDir stOutputPath
    End If
       
    Dim FileObj, MyFile
    Set FileObj = CreateObject("Scripting.FileSystemObject")
    If FileObj.FileExists(stOutputFile) Then
       Kill stOutputFile
    End If
    Set MyFile = FileObj.CreateTextFile(stOutputFile, True)
   
    '³õʼ»¯Óû§Ãû£¬Óû§ÃÜÂë
    stUserName = Worksheets("Ê×Ò³").Cells(2, 2).Value
    stUserPasswd = Worksheets("Ê×Ò³").Cells(3, 2).Value
   
End Sub
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ´´½¨Êý¾Ý¿âº¯Êý
Public Sub CreateDbSQL(ByVal OutSq


Ïà¹ØÎĵµ£º

SQLÊ¡ÊÐÇøÈý¼¶±í ˵ÉùллÔÙÄÃ

-- ±íµÄ½á¹¹ area
DROP TABLE  area;
CREATE TABLE  area (
  id int NOT NULL ,
  areaID int NOT NULL,
  area varchar(200) NOT NULL,
  fatherID int NOT NULL,
  PRIMARY KEY  (id)
)
DROP TABLE city;
CREATE TABLE  city select
  id int NOT NULL ......

SQL Server 2005&2008±¸·Ý»Ö¸´×ܽá

 
Ò»¡¢Êý¾Ý¿â´æ´¢¸ÅÊö
1¡¢Êý¾ÝÎļþÀàÐÍ
·         Primary data files:ÿ¸öÊý¾Ý¿â¶¼ÓÐÒ»¸öµ¥¶ÀµÄÖ÷ÒªÊý¾ÝÎļþ£¬Ä¬ÈÏÒÔ.mdfÀ©Õ¹Ãû¡£Ö÷ÒªÊý¾ÝÎļþ²»½ö°üº¬Êý¾ÝÐÅÏ¢£¬»¹°üº¬Óë¸ÃÊý¾Ý¿â½á¹¹Ïà¹ØµÄÐÅÏ¢¡£´´½¨Êý¾Ý¿âʱ£¬Êý¾Ý¿â½á¹¹Ïà¹ØÐÅÏ¢²»½ö´æÔÚÓÚmasterÊý¾Ý¿âÖУ¬Í¬Ê ......

½â¾ö£ºSQL Server·þÎñÎÞ·¨Æô¶¯

Æô¶¯SQL Server (SQLEXPRESS)·þÎñʱÌáʾ´íÎó£¬Ê¼þ²é¿´Æ÷ÏÔʾÒÔÏÂÐÅÏ¢£¨ID 9003£©£º
´«µÝ¸øÊý¾Ý¿â 'master' ÖеÄÈÕ־ɨÃè²Ù×÷µÄÈÕ־ɨÃèºÅ (276:232:1) ÎÞЧ¡£´Ë´íÎó¿ÉÄÜָʾÊý¾ÝË𻵣¬»òÕßÈÕÖ¾Îļþ(.ldf)ÓëÊý¾ÝÎļþ(.mdf)²»Æ¥Åä¡£Èç¹û´Ë´íÎóÊÇÔÚ¸´ÖÆÆÚ¼ä³öÏֵģ¬ÇëÖØд´½¨·¢²¼¡£·ñÔò£¬Èç¹û¸ÃÎÊÌâµ¼ÖÂÆô¶¯ÆÚ¼ä³ö´í£¬Çë´Ó± ......

sqlÓï¾ä×ܽá¶þ

sql¾«ÃîÓ÷¨
ÎÄÕ·ÖÀà:Êý¾Ý¿â
˵Ã÷£º¸´ÖƱí(Ö»¸´Öƽṹ,Ô´±íÃû£ºa бíÃû£ºb)
select * into b from a where 1<>1
˵Ã÷£º¿½±´±í(¿½±´Êý¾Ý,Ô´±íÃû£ºa Ä¿±ê±íÃû£ºb)
insert into b(a, b, c) select d,e,f from b;
˵Ã÷£ºÏÔʾÎÄÕ¡¢Ìá½»È˺Í×îºó»Ø¸´Ê±¼ä
select a.title,a.username,b.adddate ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ