LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get the DDL statement from SQL server through Excel VB.

As you know, we can connect SQL server through excel VB and we can get the
data from a DB using DML statement. And also we can create a Table on the SQL
server DB, through excel VB as command execution. The following is a simple
example I used.

Sub ExecuteDDL()
Dim Cn As New ADODB.Connection
Dim Cmd As New ADODB.Command
Dim adoRs As New ADODB.Recordset

Cn.Provider = "sqloledb"
Cn.ConnectionTimeout = 7
Cn.CommandTimeout = 0
Cn.Provider = "sqloledb"
Cn.ConnectionString = "Data Source=TEST;DSN=TEST;UID=TEST;PWD=TEST€¯
Cn.Open

Set Cmd.ActiveConnection = Cn
Cmd.CommandText = "CREATE TABLE TEST_TABLE (C1 int, C2 char(100))"
Cmd.CommandType = adCmdText
Cmd.Execute

Cn.Close
End Sub

Before the execution above, I want to get the DDL statement of a Table from
DB.
The procedure that I want is like this.
I have a Table name that I want to recreate from DB.
1. Get the create DDL statement from DB
2. Edit the DDL statement
3. Execution DDL statement
I want to process above 3 step on excel through VB, but I dont know how to
get the create DDL statement through excel macro( Number 1 step).

I can script DDL statement (Create or Drop, etc...) from DB through SQL
Sever Enterprise Manager Tool and make a text file from it.
But that way is very inconvenient to handle many tables and is required too
many manual steps.
I believe there is a way to get the statement through excel VB.
Please release my inquiry
Thanks a lot.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server -- Bulk Insert from Excel to SQL Server Madhan Excel Discussion (Misc queries) 0 December 12th 06 03:08 PM
Excel 2003 Error Cannot Locate the Internet Server or Proxy Server Seabee Excel Discussion (Misc queries) 0 November 20th 05 12:03 AM
problem updating link from Novell server to windows server #REF er Ellen Excel Discussion (Misc queries) 0 May 10th 05 09:18 PM
Excel from a Server Paul Excel Programming 1 January 20th 05 05:39 PM
SQL Statement Attaching to SQL Server Russ[_6_] Excel Programming 2 August 19th 03 06:37 PM


All times are GMT +1. The time now is 08:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"