You could use an
Identity
column in your table.
Explanation[
^]
Documentation[
^]
[Edit in response to OP comment]
Primary key is irrelevant.
IDENTITY columns get automatically generated numbers. These may not be sequential as the values are unchanged after deletions (unlike using something like ROWNUMBER() where the numbers will always be regenenerated).
For example, create a sample table
create table CP2
(
QuoteNo int IDENTITY(10001,1),
SomeOtherData varchar(max)
)
insert into CP2 values
('item 1'),
('item 2'),
('item 3')
This will automatically generate the
QuoteNo
values:
10001 item 1
10002 item 2
10003 item 3
You want yours in a particular format - so format them at the point of display e.g.
SELECT 'QU-' + CAST(QuoteNo as varchar)
from CP2
QU-10001
QU-10002
QU-10003