Hi, sorry for a newbie question but I was wondering if the following is possible:

I have to select some information from a table which I have already created a query for. This information then has to be inserted into a new table but needs another column with another unique custom identifer for each record in the format EX01 which is incremented by 1 for each record. I was wondering how is it possible to do this?

My approach was to create a view and then insert the values form the view into the new table but I still have no idea how to do the unique identifer. Was the first part of my approach correct or have been wrong from the start?

Thanks.

I think you can create identity columns.

create table #tmpTemp 
  (ID int identity(1,1),
   Code varchar(255),
   Name varchar(255))

insert #tmpTemp (Code, Name)
  select 'A', 'AA'		--> replace with your view
  union all
  select 'B', 'BB'

select * from #tmpTemp

drop table #tmpTemp
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.