SQL Lite Data Types VS T-SQL Data Types

  • yrstruly

    SSCrazy

    Points: 2807

    I am having trouble running this SQL Lite on my T-SQL. I changed the NUMBER to NUMERIC n Decimal in SQL Server. Still i am getting this error. What would be the equivalent data type in SQL Server. All of the other SQL Lite code are running on my SQL Server Express, except this:

    DROP TABLE IF EXISTS CountryLanguage;

    CREATE TABLE CountryLanguage (

    CountryCode TEXT NOT NULL DEFAULT '',

    Language TEXT NOT NULL DEFAULT '',

    IsOfficial INTEGER NOT NULL DEFAULT '0',

    Percentage NUMBER NOT NULL default '0.0',

    PRIMARY KEY (CountryCode,Language)

    );

    --

    -- Dumping data for table CountryLanguage

    --

    INSERT INTO CountryLanguage VALUES ('AFG','Pashto',1,52.4);

    INSERT INTO CountryLanguage VALUES ('NLD','Dutch',1,95.6);number data type

  • scdecade

    Old Hand

    Points: 304

    Could you explain a little more what you're trying to accomplish?  Sql Lite and Sql Server are very different databases.  From a Sql Server perspective there are a bunch of issues with the table definition you've posted.  The 'text' column type is deprecated, I think.  Some column name are reserved words (please don't ever).  Also, assigning default values to elements of a composite primary key is not typically done in Sql Server.  As far as the specific issue of 'Cannot find data type NUMBER', the intellesense has underlined the offending word for you.  If you're storing percentages then using the INT column type and dividing by 100 (when access the column) could be a useful alternative.

  • MVDBA

    SSC-Insane

    Points: 20687

    Number isn't a data type

    use decimal and specify the precision and scale

    https://docs.microsoft.com/en-us/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-2017

    MVDBA

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply