Search code examples
sql-server-2008sap-ase

Sql Server 2008: Issues while inserting the data into table


I am trying to insert a value in column in Sql Server 2008R2:

Create table Test
(
   Age varchar(3) NOT NUll
)

insert into test value ('030')

Output:
30

When i am trying same thing in Sybase:

 Output:030

Concern: I need to keep '0' in Sql Server 2008R2 too beacause it is creating some formating issues in the generated output file. Any suggestion how to retain that.


Solution

  • the syntax for SQL2008 is a bit different, {} becomes () and insert into [tablename] value () becomes insert into [tablename] values ()

    so to make it works in SQL2008.

    Create table Test
    (
       Age varchar(3) NOT NUll
    )
    insert into test values ('030')
    SELECT * FROM test
    

    by the way why do you use varchar and not char?