Comments (4)
Note that it works if I remove the `columnName := "DOCUM"` line and use the
following code for the query :
_, errQuery := db.Query(`SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name = 'DOCUM'
ORDER BY schema_name, table_name;`)
if errQuery != nil {
panic(errQuery.Error())
}
Original comment by [email protected]
on 21 Aug 2013 at 8:43
from odbc.
I have added this test
diff --git a/mssql_test.go b/mssql_test.go
--- a/mssql_test.go
+++ b/mssql_test.go
@@ -862,3 +862,37 @@
exec(t, db, "drop table dbo.temp")
}
+
+func TestMSSQLALEX(t *testing.T) {
+ db, sc, err := mssqlConnect()
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer closeDB(t, db, sc, sc)
+
+ columnName := "id"
+ rows, err := db.Query(`SELECT t.name AS table_name,
+ SCHEMA_NAME(schema_id) AS schema_name,
+ c.name AS column_name
+ FROM sys.tables AS t
+ INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
+ WHERE c.name = ?
+ ORDER BY schema_name, table_name;`, columnName)
+ if err != nil {
+ t.Fatalf("db.Query failed: %v", err)
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var table_name, schema_name, column_name string
+ err = rows.Scan(&table_name, &schema_name, &column_name)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Logf("table_name=%v schema_name=%v column_name=%v", table_name,
schema_name, column_name)
+ }
+ err = rows.Err()
+ if err != nil {
+ t.Fatal(err)
+ }
+}
that is similar to your sample. And that prints all columns named id in my
database with no problem on both Windows XP 32 bit and Linux-386 (I use
freetds-0.91 and unixODBC-2.3.1).
Maybe you should try and update your linux drivers. Not sure if I can help you
more.
Alex
Original comment by [email protected]
on 23 Aug 2013 at 2:11
- Changed state: Accepted
from odbc.
I got rid of the problem by upgrading to freetds 0.91.
Original comment by [email protected]
on 23 Aug 2013 at 6:49
from odbc.
Sounds good.
Alex
Original comment by [email protected]
on 25 Aug 2013 at 8:52
- Changed state: Done
from odbc.
Related Issues (20)
- DB2 on Windows Server 2012 R2 connect but truncate data retreived HOT 1
- DB2 for i: Simple select with empty ResultSet locks table HOT 1
- Compile errors when building from Windows OS with GOOS=linux HOT 2
- an error of SQL syntax error HOT 1
- Panic when binding `varchar`/`string` types: slice bounds out of range [:668] with capacity 256 HOT 3
- memory leak using rows.next() HOT 7
- signal 13 received but handler not on signal stack HOT 4
- Low max message length HOT 3
- Add tags to the repo HOT 1
- Implement QueryerContext interface HOT 1
- Implement RowsColumnTypeDatabaseTypeName HOT 1
- error when build from linux HOT 2
- only half of unicode string is inserted.
- Issue with Unixodbc-2.3.7 for master and for_issue_88 branch HOT 1
- 向 varchar字段保存中文中会被截断 HOT 8
- Maintain releases HOT 5
- The package is returning a panic instead of an error HOT 4
- Issues with parametrized queries Windows/DuckDB HOT 2
- abount microsoft access long binary data type HOT 1
- Unrecognized Data Type on Column
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odbc.