User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 363,556 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,862 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 27190 | Replies: 4
Reply
Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

Changing the datatype of a Column

  #1  
Jul 14th, 2005
Hello,
I want to change the datatype of a field from Varchar to integer in T-SQL.

I tried something like Modify like you use in Oracle.

ALTER TABLE tablename
MODIFY COLUMNNAME Datatype.

But its not working in SQL server..

Any thoughts.
Save White Tiger
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Posts: 19
Reputation: wchitamb is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
wchitamb wchitamb is offline Offline
Newbie Poster

Re: Changing the datatype of a Column

  #2  
Jul 14th, 2005
i am not very sure is it different as in SQL where yu can go to the database that you want and then you go to the table and then you click the right side of yur mouse and go to design table and change it
Reply With Quote  
Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

Re: Changing the datatype of a Column

  #3  
Jul 14th, 2005
I changed it. I went to enterprise Manager and went to design view of the table and changed the data type of the field.

Thanks anyway
Save White Tiger
Reply With Quote  
Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

Re: Changing the datatype of a Column

  #4  
Jul 14th, 2005
Thanks Wchitamb.
Save White Tiger
Reply With Quote  
Join Date: Jul 2005
Location: Portugal
Posts: 13
Reputation: Estuardo is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Estuardo Estuardo is offline Offline
Newbie Poster

Re: Changing the datatype of a Column

  #5  
Jul 19th, 2005
G'd evening!
In case you still need to change the table's column type from T-SQL , the sintax for MS SQL is:
ALTER TABLE table ALTER COLUMN column_name new_data_type
Ex.
ALTER TABLE MyTable ALTER COLUMN MyColumn NVARCHAR(20)

For more about the Alter Table sintax, read the books on line (BOL), here is the last update for SQL 2k SQL Server Books Online January 2004 Update
Good luck
Estuardo
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 5:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC