RSS Forums RSS
Please support our MS SQL advertiser: Programming Forums
Views: 37141 | 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: 4
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)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 9:28 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC