Get the Highest Value from the database

Posted by Venkatesh under Sql Server on 3/12/2013 | Points: 10 | Views : 972 | Status : [Member] | Replies : 5
Hi,

I have table, in that one coulmn is having data like AB001,AB002 etc.,

My question is, i need to generated this data by automatically by using linq query. How can i achieve this one?

Thanks,
Venkatesh.P




Responses

Posted by: Oswaldlily on: 3/12/2013 [Member] Starter | Points: 25

Up
0
Down
Your question is not clear...Get Highest value of AB001,AB002 ??????

var _userlist = (from r in _dc.Tablename
select new
{
Username = r.Column1,
Password = r.Column2
});

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Venkatesh on: 3/12/2013 [Member] Starter | Points: 25

Up
0
Down
I need to insert the record in to the database like AB001,AB002..AB009
After AB009 it should insert the record AB010


Thanks,
Venkatesh.P

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 3/12/2013 [Member] Starter | Points: 25

Up
0
Down
U split the values first and "numbers-0,1,2,3" in separate column
SELECT @maxnum= SELECT MAX(Column)
FROM Numbers
WHERE Col_Name = @Name

SELECT @maxnum = (SELECT CAST
( AB00 + (@maxnum+1) AS NVARCHAR(10) )

insert into tablename(column1) values(@maxnum)

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Venkatesh on: 3/12/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks for replying. i need to use linq concept

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pandians on: 3/12/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
So, What would happen after "AB999" ?

It should be "AC001" or "AB1001" ?

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response