0

I have database. Recently added two rows to the database from third party software

1) When I executed below script it not listing updated data which executed recently by third party software. But showing old data.

Select  top 5000 [T_idx]  ,[T_TAG]   ,[T_Date] from [house].[dbo].[total]

2) When I execute below code it script it showing updated data which was executed recently by third party software.

Select * from [house].[dbo].[total]
where T_TAG like '%HO%' order by T_Date DESC
5
  • 2
    MS SQL Server or MySQL? Commented Jan 10, 2014 at 9:52
  • SELECT * TOP 5000 is syntactically incorrect in both MySQL and SQL Server. Commented Jan 10, 2014 at 9:54
  • But when i am executing * Top 5000 ... ,, in SQL table data showing as per the script but it's not the latest data, Commented Jan 10, 2014 at 9:56
  • SQL Server is not automatically sorting according to your wishes. You need to add the ORDER BY to make it sort properly. Commented Jan 10, 2014 at 10:00
  • @venkat TOP keyword bring TOP data and it's not the latest data in your table , order your rows in descending and select TOP 5000 rows or use limit keyword. Commented Jan 10, 2014 at 10:06

2 Answers 2

1

top 5000 will only show the first 5000 records. quite possibly the new records are not part of that. remove top 5000

Sign up to request clarification or add additional context in comments.

2 Comments

New records are part of the Database and when executing below script it not listing the new records
@venkat Use Order By [T_Date] DESC and select TOP 5000 ,it will fetch your data or you can use LIMIT 5000 .
0

You need to order it correctly (if you want it in date order that is):

SELECT
  TOP 5000 [T_idx], [T_TAG], [T_Date]
FROM
  [house].[dbo].[total]
ORDER BY
  T_Date DESC

7 Comments

I tried above one and the results are 5000 rows are effected, msg 9002, Lvel17, State 6, Line 1 .... the Log file for database 'tempdb' is full. Backup the transaction log for the database to freeup some log space. how i can free up some space ??? where i can find 'tempdb' file ??
Ooops... that's a totally different question and is the sql server telling you that you're out of space in the tempdb. You will have to truncate the tempdb... look online for the answer.
i found the file named 'tempdb.mdf' but how could i delete some info from the file ??
yes, it showing the message, it's a large database !!! , daily transactions are updating the SQL continuously
Read this support.microsoft.com/kb/307487. The tempdb is however growing for a reason. As the name states it is a database with temporary data. According to the needs of your apps or other work hitting the tempdb you should make sure tempdb can grow. If you get this issue you can try to shrink it but if it grows back up again you'll either need to accept that it is the size required (buy more disk) or change your code to not use tempdb as much.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.