private void SetvViewColumns(SqlServerTableSchema SqlserverTable) { if (SqlserverTable == null) { return; } SqlserverTable.Columns = new List <IColumn>(); string sql = @" Select c.name As COLUMN_NAME , t.name As DATA_TYPE , o.type As OBJECT_TYPE, c.length As DATA_LENGTH, c.isnullable as NULLABLE, isnull(c.scale,0) as DATA_SCALE, c.colid as colid From SysObjects As o , SysColumns As c , SysTypes As t Where o.type in ('u','v') And o.id = c.id And c.xtype = t.xtype and t.name !='sysname' And o.Name =@TABLE_NAME "; var table = Db.Ado.GetDataTable(sql, new SugarParameter("TABLE_NAME", SqlserverTable.Name)); foreach (DataRow row in table.Rows) { int scale = Convert.ToInt32(row["DATA_SCALE"]); string data_type = row["DATA_TYPE"] + string.Empty; int len = Convert.ToInt32(row["DATA_LENGTH"]); var column = new SqlServerColumn { Name = row["COLUMN_NAME"] + string.Empty, CsharpType = SqlServerUtils.TransformDatabaseType(data_type, len, scale), DbType = data_type, IsNullable = (row["NULLABLE"] + string.Empty) == "1", Length = len, Scale = scale, Table = SqlserverTable, IsNumeric = SqlServerUtils.IsNumeric(data_type) }; SqlserverTable.Columns.Add(column); } }