How To Alter The Datatype Of A Table

Discussion in 'Databases' started by niitdebasis, Jan 9, 2009.

  1. #1
    Dear Friend I am learning SQL i need your help. Actually I was Creating a table Name-"Employee" In the field Of "Telephone_No" I have provided the datatype name "INT" so its not taking any value more than 7 digit So Now i want to change the Datatype name "INT" to "VarChar(12)" so can anybody write me the correct syntax for it. when i am giving the following syntax
    alter table Employee modify (Telephone_No VarChar(15))
    
    Code (markup):
    It showing Following Error Message [ Msg 102, Level 15, State 1, Line 1
    Incorrect syntax near '('. ]
    so plz anybody provide me the correct Syntax for this SQL.It too Urgent for me.so waiting for any reply.
    Thanks.:confused:
     
    niitdebasis, Jan 9, 2009 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    ALTER TABLE `Employee` CHANGE `Telephone_No` `Telephone_No` VARCHAR(15) NOT NULL
     
    crivion, Jan 9, 2009 IP
  3. niitdebasis

    niitdebasis Banned

    Messages:
    84
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sorry Fried Just Tried Your Code But Showing The Same Syntax Problem.
     
    niitdebasis, Jan 9, 2009 IP
  4. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #4
    impossible, what tool are you using ?
     
    crivion, Jan 9, 2009 IP
  5. niitdebasis

    niitdebasis Banned

    Messages:
    84
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I Am Using Microsoft SQL Server-2005
    You Can Suggest Me Any Better Tool For SQL.
    Thanks.
     
    niitdebasis, Jan 9, 2009 IP
  6. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #6
    mmm try one of those

    ALTER TABLE Employee ALTER COLUMN Telephone_No VARCHAR(15) NOT NULL

    or

    ALTER TABLE Employee ALTER COLUMN Telephone_No VARCHAR(15)
     
    crivion, Jan 9, 2009 IP
  7. niitdebasis

    niitdebasis Banned

    Messages:
    84
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    This Works Could You Please Advice Me any site where i can get good SQL tutorial for the beginners.
    Thanks A Lot For Solving My Problem.
    Take Care.
     
    niitdebasis, Jan 9, 2009 IP
  8. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #8
    np
    check on msdn site for best tuts
     
    crivion, Jan 9, 2009 IP
  9. niitdebasis

    niitdebasis Banned

    Messages:
    84
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks A Lot,i have no words to express how much i am happy i have bookmarked your website in my browser and from now i am your blog's regular reader.
    Take Care.
    Bye.
     
    niitdebasis, Jan 9, 2009 IP