Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to set formula for field

Author  Topic 

ameya_amu
Starting Member

25 Posts

Posted - 2009-07-05 : 00:19:15
hello friends

i have two fields with names as POid and PODid. Poid is bigint and PODid is nvarchar.
whenever poid gets store automatically podid must be get store with prefix "MRN" and then value of poid along with finacial year.

eg if value 7 get store in poid then podid must be MRN/07/09-10 where MRN is contant 07 is poid and 09-10 is finacial year.
is there any way so that i can do store podid automatically. we can get financial year as per todays date.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-05 : 02:10:40
you can update PODid with following

select PODid = 'MRN/' + right('00' + convert(varchar(2), poid), 2) + '/' + fin_year



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

ameya_amu
Starting Member

25 Posts

Posted - 2009-07-05 : 02:21:45
can backend handel this, i dont want to code i.e u say that i should write given code trigger. can it be automatic i dont want to write code.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-05 : 02:39:09
then check out trigger. Use trigger to update PODid whenever podid is inserted or updated.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-05 : 02:44:05
you can add PODid as a calculated column.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-05 : 02:54:30
quote:
Originally posted by visakh16

you can add PODid as a calculated column.



Might not be possible due to the financial year.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

ameya_amu
Starting Member

25 Posts

Posted - 2009-07-05 : 04:03:49
then skip financial year i will store in another field
Go to Top of Page
   

- Advertisement -