Left or Length Command

  • I have a field that contains data such as 'ACB00/02'. How would I write into a function that gathers a load of data together for me a peice of code that will grab only the first 2 chars of the afore mentioned value, So the result would be in the new created colum in a temp table 'AC'.

    This is to occur over 7,000 records but they are not all AC, I just want the first two from every line.

    Regards

  • update table set newcolumn = left(oldcolumn,2)

    [font="Comic Sans MS"]The GrumpyOldDBA[/font]
    www.grumpyolddba.co.uk
    http://sqlblogcasts.com/blogs/grumpyolddba/

  • or you could use a computed column

    [font="Comic Sans MS"]The GrumpyOldDBA[/font]
    www.grumpyolddba.co.uk
    http://sqlblogcasts.com/blogs/grumpyolddba/

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply