July 13, 2007 at 3:03 pm
I have a column which is a VARCHAR(1000). Come to findout out client's data structure can only handle up to 255. How would I go about taking my VARCHAR(1000) column and splitting it out into smaller VARCHAR(255) columns?
July 13, 2007 at 3:12 pm
You mean like this?
Col1 = Substring(MainColumn,1,250)
,Col2 = Substring(MainColumn,251,250)
,Col3 = Substring(MainColumn,501,250)
,Col4 = Substring(MainColumn,751,250)
Note, you can use left for the first string, but I used Substring to be consistent.
July 17, 2007 at 3:12 pm
How would you run this?
In an ALTER TABLE STATEMENT?
July 17, 2007 at 3:19 pm
Are you inserting your one field into the clients 4 already existing fields or are you adding the fields to the clients table or are you adding the 4 new fields to your table and then updating the records with new info or is this part of an application that needs to automatically populate the 4 new fields when the one field is inserted or updated?
July 17, 2007 at 3:32 pm
I am adding 4 new column into an already existing table then updating them.
July 17, 2007 at 3:39 pm
July 17, 2007 at 3:46 pm
I got that to work but wht I need now is to Drop the original column (not a problem) but then rename one of the new column back to the original name but there is now RENAME in the ALTER TABLE statement.
July 17, 2007 at 3:51 pm
July 17, 2007 at 5:58 pm
Lookup sp_Rename in Books Online... that'll do what you need...
--Jeff Moden
Change is inevitable... Change for the better is not.
July 18, 2007 at 7:45 am
July 19, 2007 at 7:49 am
This did the trick. Thanks for everybodies help.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply