Code Monkey home page Code Monkey logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on May 26, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 26, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 26, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 26, 2024
Sounds good.

Alex

Original comment by [email protected] on 25 Aug 2013 at 8:52

  • Changed state: Done

from odbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.