Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2007
    Posts
    27

    Question Unanswered: DateTime Column Named Timestamp

    I'm trying to get data from a Sybase database for a DAL in VB.net via a DataSet object (.xsd file). This in and of itself isn't a problem, except that the tables that I am trying to access have a column named Timestamp, which is a DateTime type column. This means that when I attempt to select that column, it thinks I'm referring to the data type Timestamp rather than the name of the column, which of course causes an error. I've tried every possible way that I can think of to select that column, but to no avail. Brackets [Timestamp] don't work. Quotes "Timestamp" just select the literal string "Timestamp". I can't even give it an alias, because any attempt to tell the alias what to refer to runs into the exact same problem.

    Please note that I only have read access to this database, so I am unable to create any views or copy the data to a temporary table with a new name for Timestamp (options I had considered, but which obviously didn't pan out).

    There MUST be a way to be able to select that column within the DataSet object. Do I need a new type of connection (right now I'm connecting through a Microsoft ODBC Data Source)? Is there some other way of renaming that column so that I can select it? I've only ever worked through the designer, so is there something that I can do to the underlying code of the .xsd file directly to make it work? This is seriously killing me.

  2. #2
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    As far as Sybase goes, its possible to use timestamp as a columnname:
    select col1, timestamp from mytable
    where timestamp > '2010/06/01'

    should work (at least it does for me). You can give a column an alias, but it's not possible to refer to it by it's alias.
    select col1, timestamp as columnalias from mytable
    where columnalias > '2010/06/01'

    give an error.

    I don't know what kind of Sybase-db you're using, but in ASE you almost always have acces to the tempdb to create temporary tables. Maybe that works for you, instead of creating temptables in the application-database.
    I'm not crazy, I'm an aeroplane!

  3. #3
    Join Date
    May 2008
    Location
    Bavaria
    Posts
    3
    I have SQL Anywhere 10 and since couple of hours also 12. Below select works fine:
    Code:
    select timestamp as "time stampa" from tista 
        where "time stampa" < '2010-07-22 00:00:00.000';
    
    /* result:
    time stampa
    -----------------------
    2010-07-21 22:23:24.567
    */
    
    create table tista (timestamp timestamp);
    insert into tista (timestamp) values ('2010-07-21 22:23:24.567');
    commit;
    PS Interactive SQL is connected through sybase ODBC driver to database, this also functions within Java/JDBC and C++/ODBC.

    Maybe the mistake is that you are using Microsoft ODBC driver for MS SQL Server does NOT allow that column name (your Timestamp) is identically equal to a system name (TIMESTAMP) but Sybase does!
    Last edited by tesuji; 07-21-10 at 20:05.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •