January 2, 2007 at 2:32 pm
i have a table Called GE_Trans which has a column TreatyNumber which has values
like below
Sample data
TreatyNumber
MRQYP2A2
MRQYP3A1
MRQYS2A2
i want to add a new field to this table called TreatyID with datatype bigint
and write in this field either 2 OR 3 as it is depends on the 6th Digit in
the TreatyNumber field.
what i mean by this is for instance by looking at te sample data in the first instance
TreatyNumber is MRQYP2A2 (6th Digit in the TreatyNumber field is 2 which i want to write in my new field TreatyID)
January 2, 2007 at 2:34 pm
January 2, 2007 at 2:43 pm
i know how to use it but i dont know how to use it in this case
can you guide me please
January 2, 2007 at 2:45 pm
January 2, 2007 at 2:49 pm
from BOL:
SELECT SUBTRING(FirstName,1,1) AS Initial, LastNameFROM Employees
This is the result set:
Initial..........LastName-------------------------A................FunkM................PearsonL................CalafatoN................DannerJ................LeeS................ByhamM................SutterR................KingA................Doyle
January 2, 2007 at 2:51 pm
guys, sorry for messing up the formatting. will be more careful next time.
January 2, 2007 at 2:56 pm
Can you write the actual query to show me becz i am still not cleared fully.
Thanks
January 2, 2007 at 3:03 pm
January 2, 2007 at 3:13 pm
January 2, 2007 at 3:13 pm
update the data
January 2, 2007 at 3:18 pm
January 2, 2007 at 3:45 pm
Also keep in mind that what you've asked for will only set the TreatyID values for existing rows. You will need to also take care of populating the TreatyID for new rows inserted into your table.
January 2, 2007 at 7:57 pm
John Rowan is correct about the existing rows... that's why some have suggested that the new column be a "calculated column" (see CREATE TABLE and ALTER TABLE in Books Online for how to make one). Creating a "real" column for this would actually be a violation of 3rd normal form because you are duplicating data in columns....
--Jeff Moden
Change is inevitable... Change for the better is not.
January 2, 2007 at 9:05 pm
Thanks for the help to all of you
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply