Sub ConnectSqlServer() Dim conn As ADODB.Connection Dim rs As ADODB.Recordset Dim sConnString As String Dim squery As String ' Create the connection string. sConnString = "Provider=SQLOLEDB;Data Source=RCHNLPT136\SQLEXPRESS2014;" & _ "Initial Catalog=ExpenseMgmt;" & _ "user id=sa;password=Welcome@123;" & _ "Integrated Security=SSPI;" ' Create the Connection and Recordset objects. Set conn = New ADODB.Connection Set rs = New ADODB.Recordset ' Open the connection and execute. conn.Open sConnString squery = "select " & _ " tb.TABLE_SCHEMA as TableSchema, tb.TABLE_NAME as TableName," & _ " sum(Case When DATA_TYPE = 'int' then 4 else 0 end + Case When DATA_TYPE = 'nvarchar' and CHARACTER_MAXIMUM_LENGTH > 0 then CHARACTER_MAXIMUM_LENGTH * 2 When DATA_TYPE = ...
select tb.TABLE_SCHEMA as TableSchema, tb.TABLE_NAME as TableName, sum( Case When DATA_TYPE = 'int' then 4 else 0 end + Case When DATA_TYPE = 'nvarchar' and CHARACTER_MAXIMUM_LENGTH > 0 then CHARACTER_MAXIMUM_LENGTH * 2 When DATA_TYPE = 'nvarchar' and CHARACTER_MAXIMUM_LENGTH 18 then 16 else 0 end + Case When DATA_TYPE = 'Numeric' and Numeric_Precision