See example in C:
private DataSet selectID(string studentId)
{
SqlConnection conn = "connecttoserverstring";
SqlCommand cmd = new SqlCommand("select 'M-' + cast(ID as varchar(10)) from table, conn);
SqlParameter p = new SqlParameter("@id", studentId);
}
Even that the id is a int we cast it into a varchar
so we can concatenate
it with the 'M-' or what ever you want !
Simple example of the output is :
- run this in SQL Server.
select 'M-' + cast(1 as varchar(10));