January 18, 2010 at 4:19 am
Hi
i have a table like following structure
Roll_No S_Name Subject Branch
now i need to fetch the record id of this table can any one tell me how can i do so
January 18, 2010 at 4:31 am
check for Row_number() in BOL.
January 18, 2010 at 4:34 am
How to do so??
Can you send me query for this
January 18, 2010 at 4:37 am
How about some sample data. Please see my first link in the signature below.
January 18, 2010 at 7:49 am
amitsingh308 (1/18/2010)
now i need to fetch the record id of this table can any one tell me how can i do so
What exactly do you mean by Record ID? What are you trying to do here?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 19, 2010 at 4:11 am
send some sample data and ur requirement ?
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
January 19, 2010 at 4:35 am
As we know that each row have its own id in each table provided by DMBS software. I want to fetch that row ID for specific table
January 19, 2010 at 4:45 am
SQL Server does not have a 'row ID' assigned to each row by the DB engine. Oracle may (I think), but SQL doesn't.
What problem are you trying to solve here? I'm sure we can give you an alternative
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 19, 2010 at 5:00 am
is this what u looking for ?
create table #tmp
(
Roll_No int,
S_Name nvarchar(100),
Subject nvarchar(100),
Branch nvarchar(20))
insert into #tmp
select 1 , 'jack', 'Bio', 'A' union
select 1 , 'alex', 'tech', 'f' union
select 1 , 'Sona', 'Arts', 'A' union
select 1 , 'jin', 'Gym', 'b'
select row_number() over (order by Roll_No ,S_Name ,Subject, Branch ) as ROW_NUMER , *
from #tmp
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
January 19, 2010 at 5:13 am
Actually I went for an interview there interviewer asked me for retrieve row id from a specific table. But I replied so confidently that sql server doesn't assign any Row Id for tables. But I know in Oracle n mysql provides an Id for each row so that I was just conforming is there any thing like that is sql server. So that I asked ?? if there is any then can you tell me how can i retrive row id?
January 19, 2010 at 5:15 am
amitsingh308 (1/19/2010)
But I know in Oracle n mysql provides an Id for each row so that I was just conforming is there any thing like that is sql server. So that I asked ??
SQL Server does not provide an id for a row.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 19, 2010 at 5:28 am
amar , try to run the script i pasted in my previous past and u will find reply
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
January 19, 2010 at 5:42 am
Bhuvnesh (1/19/2010)
amar , try to run the script i pasted in my previous past and u will find reply
The Row_Number function is not the same as the RowID that Oracle and MySQL provides.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 19, 2010 at 5:45 am
can u post the link ? where i can find the difference between them
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
January 19, 2010 at 5:46 am
I'd start with google.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply