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 2008 Forums
 Transact-SQL (2008)
 Inserting row at specific position in table

Author  Topic 

Swati Jain
Posting Yak Master

139 Posts

Posted - 2009-07-28 : 07:50:12
Hello All,

While inserting row in table is it possible , inserting row at Particular row number

suppose
date in tabl --2/7/2009

value to be inserted --2/6/2009

after inserting 2/6/2009
2/7/2009--as it is max
value to be inserted -- 2/8/2009
sequence -- 1)2/7/2009
2)2/8/2009 -- as this is max

I am retricted to use order by clause.. what to do. pls tell asap

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-28 : 08:31:09
What is wrong with using Order by?

Madhivanan

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

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2009-07-28 : 08:46:13
What is row number? there is no such thing unless you calculate it when you select your data. Are you using access perhaps?

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-07-28 : 13:33:34
You never have to Insert rows at specific positions in table!
Don't waste your time with that idea.

The wanted order is always to realize when you are retrieving data via select using order by.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-07-28 : 14:18:50
The only way to control the order that data is stored is by creating a CLUSTERED index.
The only way to guarantee the order of selected results is to use an ORDER BY clause.

As Madhi asked:
"I am retricted to use order by clause"
Are you saying you can't use an order by clause? Why not???

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -