Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!
Sub readSQLstructure() Dim DBConn As New ADODB.Connection Dim RSConn As New Recordset Sheets("SQL Structure").Activate ActiveSheet.Cells.Clear DBConn.Open ("Provider=SQLOLEDB.1;User ID=user;Password=password;Initial Catalog=catalog;Data Source=server;") With RSConn tblno = 1 tblnos = 5 For tblno = 1 To tblnos nextrow = ActiveSheet.UsedRange.Rows.Count + 1 If nextrow = 2 Then nextrow = 1 End If thistbl = Choose(tblno, "Assignments", "Equipment", "Faults", "Theatres", "Users") Sql = "SELECT ORDINAL_POSITION AS POSITION, TABLE_NAME, COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH AS MAX_LENGTH, COLUMN_DEFAULT, IS_NULLABLE As ALLOW_NULL FROM INFORMATION_SCHEMA.Columns WHERE Table_Name = " & "'" & thistbl & "'" RSConn.Open Sql, DBConn Worksheets("SQL Structure").Range("A" & nextrow).CopyFromRecordset RSConn RSConn.Close Next tblno End With DBConn.Close End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.