'====================================================
'LISTS ALL TABLES / COLUMNS AND SAVES TO TEXT FILE
'====================================================


Dim Conn, strSQL, rs
Set Conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
Conn.Open "DSN=ezrets demo" 'your dns here



Set rs = Conn.OpenSchema(4) '20 = tables    4 = tables and columns
do until rs.eof
	
	for each thing in rs.fields
		if thing.name <> "" then msg = msg & thing.name & vbtab & vbtab & thing.value & vbcrlf
	next
	
	TableName = rs("TABLE_NAME")
	ColumnName = rs("COLUMN_NAME")
	
	rs.movenext
loop
msgbox msg




writetofile "c:\ezrets_list.txt", msg, false




function writeToFile(FileName, Content, Append)
	'on error resume next
	
	if Append = true then 'We will append the data to the end of the file
	   iMode = 8
	else 'We will start from the beginning of the file and write over what ever is there from beginning to end
	   iMode = 2
	end if
	
	set oFs = createobject("Scripting.FileSystemObject")
	set oTextFile = oFs.OpenTextFile(FileName, iMode, True)
	oTextFile.Write Content
	oTextFile.Close
end function