Click here to Skip to main content
15,072,933 members
Home / Discussions / Database
   

Database

 
GeneralRe: Get columns name Pin
Victor Nijegorodov4-Jun-21 7:21
MemberVictor Nijegorodov4-Jun-21 7:21 
GeneralRe: Get columns name Pin
Gerry Schmitz4-Jun-21 7:54
mveGerry Schmitz4-Jun-21 7:54 
GeneralRe: Get columns name Pin
Victor Nijegorodov4-Jun-21 8:02
MemberVictor Nijegorodov4-Jun-21 8:02 
GeneralRe: Get columns name Pin
Gerry Schmitz4-Jun-21 9:01
mveGerry Schmitz4-Jun-21 9:01 
GeneralRe: Get columns name Pin
Victor Nijegorodov4-Jun-21 9:47
MemberVictor Nijegorodov4-Jun-21 9:47 
AnswerRe: Get columns name Pin
Mycroft Holmes4-Jun-21 12:43
professionalMycroft Holmes4-Jun-21 12:43 
AnswerRe: Get columns name Pin
mverbeke31-Aug-21 3:59
Membermverbeke31-Aug-21 3:59 
SuggestionRe: Get columns name Pin
Richard Deeming31-Aug-21 4:50
mveRichard Deeming31-Aug-21 4:50 
I suggest you read the documentation:
Column IDs might not be sequential.
If a column has ever been dropped from the table, you will end up with gaps in the column ID sequence.

To get a true ordinal position, you'd need to use the ROW_NUMBER windowing function - for example:
SQL
SELECT [name], ROW_NUMBER() OVER (ORDER BY [column_id]) As [Ordinal]
FROM sys.columns
WHERE [object_id] = OBJECT_ID('MyTable')
ORDER BY [column_id]




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

QuestionSQL statements Pin
Erick Kaira27-May-21 8:09
MemberErick Kaira27-May-21 8:09 
AnswerRe: SQL statements Pin
Victor Nijegorodov27-May-21 8:40
MemberVictor Nijegorodov27-May-21 8:40 
AnswerRe: SQL statements Pin
SeanChupas27-May-21 9:02
MemberSeanChupas27-May-21 9:02 
QuestionRe: SQL statements Pin
David Crow27-May-21 9:12
MemberDavid Crow27-May-21 9:12 
AnswerRe: SQL statements Pin
Mycroft Holmes27-May-21 12:19
professionalMycroft Holmes27-May-21 12:19 
QuestionSQL query dilemma Pin
David Crow20-May-21 10:31
MemberDavid Crow20-May-21 10:31 
AnswerRe: SQL query dilemma Pin
Mycroft Holmes20-May-21 13:05
professionalMycroft Holmes20-May-21 13:05 
QuestionAccounting problem in SQL Pin
Member 1400680615-May-21 23:23
MemberMember 1400680615-May-21 23:23 
AnswerRe: Accounting problem in SQL Pin
Mycroft Holmes16-May-21 12:17
professionalMycroft Holmes16-May-21 12:17 
AnswerRe: Accounting problem in SQL Pin
CHill6019-May-21 2:55
mveCHill6019-May-21 2:55 
QuestionSQL Server Execution Timeout Expired Pin
idkd12-May-21 23:00
Memberidkd12-May-21 23:00 
AnswerRe: SQL Server Execution Timeout Expired Pin
SeanChupas13-May-21 1:49
MemberSeanChupas13-May-21 1:49 
QuestionIn-memory database with acid transactions and high availability Pin
Mathieu Seillier12-May-21 2:54
MemberMathieu Seillier12-May-21 2:54 
AnswerRe: In-memory database with acid transactions and high availability Pin
Mycroft Holmes12-May-21 13:00
professionalMycroft Holmes12-May-21 13:00 
AnswerRe: In-memory database with acid transactions and high availability Pin
Richard MacCutchan12-May-21 21:08
mveRichard MacCutchan12-May-21 21:08 
QuestionSQL Server round trip issue between server and client pc Pin
Mou_kol1-May-21 6:35
MemberMou_kol1-May-21 6:35 
AnswerRe: SQL Server round trip issue between server and client pc Pin
Mycroft Holmes1-May-21 11:57
professionalMycroft Holmes1-May-21 11:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.