How to connect to a Teradata database on a remote server

Szurya

New Member
Joined
Jul 18, 2012
Messages
2
Hello friends,

I need help in connecting to a Teradata database on a remote server. I could comeup with a VBA for connecting to 'Teradata' database locally with in that server and want to move my solution a step further where the user would be able to connect to the database in a server and get the result into the Excel sheet in their local system.

This is what I'm doing now
1. Connect to the server via 'mstdc' in windows, enter User ID and Password Manually.
2. Once connected, open an excel sheet and run this below VBA script, which connects to the Teradata database and runs a query(built in the VB script) and provide the result.

My VB Script:

Code:
Sub CommandButton1_Click()


CreateObject ("ADODB.Connection")
Dim conn As ADODB.Connection
Dim rec1 As ADODB.Recordset
Dim thisSql As String


Set conn = New ADODB.Connection


conn.Open ("DRIVER={Teradata};DBCNAME=xxx.xx.xx.xx;UID=xxxx;PWD=xxyy;QUIETMODE=YES;")


thisSql = ""
thisSql = thisSql & " SELECT         calendar_date, a.Section_Number,a.class_number,a.subclass_number, "
thisSql = thisSql & " cast(SUM(Sales_Value) as decimal(18,4)) sales_value, "
Set rec1 = New ADODB.Recordset
rec1.Open thisSql, conn


With Sheet1.QueryTables.Add(Connection:=rec1, Destination:=Sheet1.Range("A1"))
    .Name = "data"
    .FieldNames = True
   .Refresh BackgroundQuery:=False
End With


End Sub


Thanks
Surya
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,263
Messages
5,769,117
Members
425,518
Latest member
seothaeng

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top