954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Query logic

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.

Jon182
Junior Poster in Training
91 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

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
huangzhi
Light Poster
48 posts since Feb 2008
Reputation Points: 10
Solved Threads: 13
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You