Uri Dimant
3/21/2007 11:41:00 AM
Hi,Roy
> Please consider storing this information in three columns, not one.
While writing my post I assumed that the OP has a three columns and wanted
fourth column, now that I read you post Isee that the OP has only one column
to be concatinated. Thanks
"Roy Harvey" <roy_harvey@snet.net> wrote in message
news:um520354gvcg2qat4ejn85uhgv256i1qda@4ax.com...
> You realize that the next thing you will be doing is writing a query
> to return all the rows for a department?
>
> WHERE SUBSTRING(Project_ID,5,3) = '055'
>
> Please consider storing this information in three columns, not one.
>
> As for the use of identity, it does not fit this case at all. You are
> looking for each year/department to sequence from 1, incrementing by
> 1, are you not? Identity gives one sequence for the table, not for
> any group of rows. You will have to calculate the "next number"
> yourself during the INSERT.
>
> Roy Harvey
> Beacon Falls, CT
>
> On Wed, 21 Mar 2007 01:30:14 -0700, Maurice
> <Maurice@discussions.microsoft.com> wrote:
>
>>Hi there,
>>
>>Hope that anyone can help me on this one.
>>
>>I want to create a key column which consists of the following:
>>Year/Dept.nr/Incrementnumber
>>
>>By that I mean when I insert a record in the table I want de field
>>Project_ID to be like this: 20070551 being the year 2007 dept.nr being 055
>>and 1 for being the increment number.
>>
>>For the incrementnumber can I use something like @@Identity to get the
>>last
>>used Identity and then concatenate the string? If so how do I go about it?
>>
>>I have a table with Id field set to Identity(1,1). The departmentnumbers
>>will be designatedand the year should be the current year.
>>
>>
>>Any help appreciated.
>>
>>Maurice