Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Increment Column

Author  Topic 

ofsouto
Starting Member

22 Posts

Posted - 2005-06-17 : 13:20:40
I want to show all registers from a table(CODE, DESCRIPTION) and show an additional collum with the row number(INCREMENT).

Select * from table_1

RESULT:
CODE DESCTIPTION INCREMENT
-------- ------------------------- -----------
03354718 FIRST_DESCRIPTION 1
54654654 SECOND_DESCRIPTION 2
62173620 THIRD_DESCRIPTION 3

How can I get it?
Thank you very much

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-06-17 : 13:25:58
Select identity(1,1) as inc, *
into #temp
from table_1

select * from #temp

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-18 : 03:34:56
Mladen, when I run that query, I get the error

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '1'.

anything wrong?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-06-18 : 13:37:36
One parameter was missing:
select
identity(int,1,1) as inc,
*
into
#temp
from
table_1

select * from #temp


CODO ERGO SUM
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-20 : 00:43:05
Yes, Datatype is missing. Thanks

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -