locked
SQL 2008 VARCHAR & CHAR DATA TYPES NOT WORKING RRS feed

  • Question

  • Hi Folks,

    I downloaded SQL 2008 and installed recently.Everything perfectly works except one thing that I can't use VARCHAR AND CHAR data types anymore.I was using SQL 2005 and I had the same problem there as well.

    Please helpe to solve this problem

    Tuesday, September 7, 2010 3:30 PM

Answers

  • Char and varchar are not supported as SQL CE is unicode ...you need to use Nchar and nvarchar.

    Try it .It should work ...

    Regards


    Abhay Chaudhary OCP 9i, MCTS/MCITP (SQL Server 2005, 2008, 2005 BI) ms-abhay.blogspot.com/
    • Proposed as answer by WeiLin Qiao Thursday, September 9, 2010 2:03 AM
    • Marked as answer by SriLankan Thursday, September 9, 2010 8:40 AM
    Wednesday, September 8, 2010 4:05 AM

All replies

  • Hi,

    Could you please let us know more details about your issue?

    You can use varchar and char data type in tables or scripts on SQL 2005 and 2008 R2.

    http://msdn.microsoft.com/en-us/library/ms176089.aspx

     


    Ramesh S
    www.sequalserver.com
    Tuesday, September 7, 2010 5:14 PM
  • Like this no one would be able to understand your issue and give you solutions .

    Please post the error you are getting when you use these datatypes .


    Abhay Chaudhary OCP 9i, MCTS/MCITP (SQL Server 2005, 2008, 2005 BI) ms-abhay.blogspot.com/
    Tuesday, September 7, 2010 5:30 PM
  • There is no changes between SQL Server 2005 and SQL Server 2008 for VARCHAR and CHAR dataypes. Can  you provide more details about the problem?
    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
    Tuesday, September 7, 2010 5:54 PM
    Answerer
  • Hey Guys,

    First of all thanks for the rapid replies.

    As you all know when you open SQL 2008 Management Server you get a window called"connect to server". In my campus, I can directly connect to campus server but at home I cant find a server in server list.Therefore what I do is choose SQL server compact edition instead of the database engine in server type field, and then create a new database file and use it as my working platform for SQL 2008.

    There comes the problem of CHAR & VARCHAR type not working even though I dnt know what other data types are not working.Normally when you type a SQL command it always displayed in blue.Isn't it? But VARCHAR nothing happens and  for CHAR...as Example:CHAR(20)...the brackets can be seen bold. But of course not in blue. And I cant execute any commands with these data types it gives an error message ,This was my command

    CREATE TABLE Student(
    Name CHAR(20) PRIMARY KEY,
    NICno VARCHAR,
    gpa REAL,
    Position INT,
    );

    For this I got the following error msg.

    Major Error 0x80040E14, Minor Error 26302
    > CREATE TABLE Student(
    Name CHAR(20) PRIMARY KEY,
    NICno VARCHAR,
    gpa REAL,
    Position INT,
    )
    The specified data type is not valid. [ Data type (if known) = CHAR ]

     

    It might be I am working in Compact Edition of either....Please help me to solve this problem.

    Wednesday, September 8, 2010 2:10 AM
  • Char and varchar are not supported as SQL CE is unicode ...you need to use Nchar and nvarchar.

    Try it .It should work ...

    Regards


    Abhay Chaudhary OCP 9i, MCTS/MCITP (SQL Server 2005, 2008, 2005 BI) ms-abhay.blogspot.com/
    • Proposed as answer by WeiLin Qiao Thursday, September 9, 2010 2:03 AM
    • Marked as answer by SriLankan Thursday, September 9, 2010 8:40 AM
    Wednesday, September 8, 2010 4:05 AM
  • Thanx for the answer Abhay78,

    As you said nchar and nvarchar works perfectly.

     

    Please tell me why I am getting this error message.

    Major Error 0x80040E14, Minor Error 25501
    > create table Student (
    name nchar(10),
    number int,
    gpa real,
    nicno nvarchar,
    )
    There was an error parsing the query. [ Token line number = 6,Token line offset = 1,Token in error = ) ]

     

    MY COMMAND WAS

    create table Student (
    name nchar(10),
    number int,
    gpa real,
    nicno nvarchar,
    );

     

    Thank you

    Wednesday, September 8, 2010 6:01 AM
  • Hi ,

    Just remove Comma on nico navrchar.

     

    create table Student (
    name nchar(10),
    number int,
    gpa real,
    nicno nvarchar, ---- Remove comma here.
    );


    Ramesh S
    www.sequalserver.com
    Wednesday, September 8, 2010 6:06 AM
  • oh yeah, tnx man...see how good I am at SQL....but i like it so much...still improving I really appreciate you guys trying to help someone like this..... warm regards, cheerzzzzzz....
    Wednesday, September 8, 2010 8:00 AM
  • Yr very welcome.Ramesh, good catch.

    Regards


    Abhay Chaudhary OCP 9i, MCTS/MCITP (SQL Server 2005, 2008, 2005 BI) ms-abhay.blogspot.com/
    Wednesday, September 8, 2010 10:33 AM