• well based on how i read your description, it sounds like a simple calcuated column could be used;

    ALTER TABLE [dbo].[GV_STNDetails]ADD STN AS RIGHT('0000' + CONVERT(VARCHAR,[From_StoreCode]),4) +RIGHT('000000' + CONVERT(VARCHAR,[STNID]),6) PERSISTED

    if you run this example in tempdb, is this giving you the results you are looking for?

    /*

    --Results

    STNID CourierName AWBNo DispatchedDate STNNO From_StoreCode TO_StoreCode STN

    ----------- ------------------------------ ----------- ----------------------- -------------------- -------------- ------------ ----------

    1 FedEx 14 2013-04-17 07:22:26.040 PO-14 5 6 0005000001

    2 UPS 42 2013-04-17 07:22:26.040 PO-15 1 1 0001000002

    */

    CREATE TABLE [dbo].[GV_STNDetails] (

    [STNID] INT IDENTITY(1,1) NOT NULL,

    [CourierName] VARCHAR(30) NULL,

    [AWBNo] INT NULL,

    [DispatchedDate] DATETIME NULL,

    [STNNO] VARCHAR(20) NULL,

    [From_StoreCode] INT NULL,

    [TO_StoreCode] INT NULL,

    STN AS RIGHT('0000' + CONVERT(VARCHAR,[From_StoreCode]),4) +RIGHT('000000' + CONVERT(VARCHAR,[STNID]),6) PERSISTED)

    INSERT INTO GV_STNDetails(CourierName,AWBNo,DispatchedDate,STNNO,From_StoreCode,TO_StoreCode)

    SELECT 'FedEx',14,getdate(),'PO-14',5,6 UNION ALL

    SELECT 'UPS',42,getdate(),'PO-15',1,1

    SELECT * FROM GV_STNDetails

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!