0

I'm trying to insert records for couple of columns from a physical table into a temp table with customized IDENTITY. It creates the identity column (field name = idnum), but the values are 0 for all rows. I'm using below code. If anyone can help me what I'm doing wrong would be greatly appreciated.

Note: I'm trying this is Sybase ASE 15.7

SELECT
  * INTO #achu_test
FROM (SELECT TOP 10
  idnum = IDENTITY(8),
  First_Name,
  Last_Name
FROM Employees) myTable
superachu
  • 823
  • 3
  • 16
  • 34
  • My bad! I misplaced the IDENTITY. instead of using it before "* INTO", I used inside the Subquery. SELECT idnum = IDENTITY(8),* INTO #achu_test FROM (SELECT TOP 10 First_Name, Last_Name FROM Employees) myTable A good sleep might have given the result for me :) – superachu Apr 21 '16 at 12:52
  • You're allowed to answer your own question (eg: with the contents of your comment). – crw Jul 25 '16 at 16:44
  • thanks bro, i posted! – superachu Jul 28 '16 at 15:35
  • No problem. I found the information useful as I ran into a similar issue. – crw Jul 29 '16 at 08:56

1 Answers1

1

My bad! I misplaced the IDENTITY. instead of using it before "* INTO", I used inside the Subquery.

SELECT idnum = IDENTITY(8),* INTO #achu_test 
FROM (SELECT TOP 10 First_Name, Last_Name FROM Employees) myTable

A good sleep might have given the result for me :)

superachu
  • 823
  • 3
  • 16
  • 34