Dear All,
A table is there named tbl_ProductCatg in my Database (in SQl Server 2008)
with fields Id,Code,Description and a few more.
Id field is autoincremented and I have to insert this field value in Code field.
i.e. if Id generated is 1 then in Code field the value should be inserted like 0001(formatted for having length of four),if id is 77 Code should be 0077.
For this,I made the query like:
insert into tbl_ProductCatg(Code,Description) values(RIGHT('000'+ltrim(Str(SCOPE_IDENTITY()+1,4)),4),'testing')
This query runs well in sql server query analyzer but if I write this in C# then it insets Null in Code even Id field is updated well.
Looking for kind solutions of Yours
Thanks in advance
Supriya