My Out put like This : If it is North "N00001
N00002
If it is South "S00001
S00002
Hier ist mein Versuchte-CodeWie wird eine 5-stellige Inkrementnummer basierend auf Zone generiert?
Declare @Zone varchar(20),@ZoneID int,@id varchar(10)
Set @Zone = 'S'
Select @ZoneID = cast(isnull(max(cast(replace(Idno,@Zone,'') as numeric))+1,'00000') as varchar) from memberprofiles Where left(idno,1) = @Zone
Set @id = @Zone+cast(@ZoneID as varchar)
select @id
Aber jedes Mal wenn ich "S1" bin immer Aber ich brauche "S00001"
Wie kann ich Zone weist Anzahl Generation
http://stackoverflow.com/questions/16760900/pad-a-string-with-leading-zeros-so-its-3-characters-long-in-sql- Server-2008 –