|
The only caveat you need to remember is that the datatable select consumes quite a bit of memory as it has to go through every record in the table. Be sure to set a primary key column and index if possible.
Aaron
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
Is there any way to view next or previous data of SQL database without using SQLDataAdapter and DataSet. If there is then how?? And If there is no way then what's the procedure of using these two thing?
|
|
|
|
|
Saiyed Alam wrote: view next or previous data of SQL database without using SQLDataAdapter and DataSet
Why do you want to not use DataAdapter or DataSet? Any particular reason?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
The SqlDataReader can only present a forward-only, read-only result set. This is a change from the old ADO Recordset days mainly because the programming model tended to lead to applications holding result sets, and hence transactions, open for a long time and blocking each other. ADO.NET offers a disconnected-only model to avoid these problems (if appropriate, a provider can offer a connected model, for example SQL Server Compact Edition, which is an in-process database engine, offers the SqlCeResultSet class which provides scrolling and updateable result sets).
The normal approach is simply to construct a SqlDataAdapter object, set the SelectCommand property to a command object with the appropriate command, then call Fill on the data adapter to get the results.
If using data binding of Windows Forms controls, the CurrencyManager class can help manage the current position in the DataTable or DataSet .
|
|
|
|
|
Hi All,
I want to pass the table from Server to My PC. Particular table values only I want. How can I fetch the values from Server using DTS.
I'm using Sql server 2005.Give me any sample.
Thanks in Advance
|
|
|
|
|
I think you need to rephrase your question. As it currently stands, it makes very little sense. What do you mean "pass the table"
It sounds like you want to query a table for some specific rows using some application running on your PC to get data from some server (on your local network?). Why you would think DTS was appropriate is beyond me...unless you want to store the data locally in a different database, after extracting it from SQL 2k5.
|
|
|
|
|
Hi,
I want to know more abt DTS. If u have any samples,msg me.
I Created the sample dtsx in BI successfully. Is there any way to see the coding for dtsx?
Thanks in advance
|
|
|
|
|
Hi All,
I am not really a database guy,And i wanted to do indexing on my tables as they now have a slow response when i run a qurey!!!
Could you please give the steps to index the database so that i can get a better performance?
Thanks and best regards
|
|
|
|
|
|
This SQL Statement:
SELECT CAST(2.78 AS FLOAT)
Returns in SQL Server 2005 as: 2.78
But....
Returns in SQL Server 2000 as: 2.7799999999999998
Obviously 2.78 <> 2.7799999999999998
Where can I set my SQL Server 2000 to not do this!
_______________________________________________________________________
http://www.readytogiveup.com/[ ^]
"you can't forget something you never knew..." M. Du Toit
|
|
|
|
|
decimal can be used instead of Float
CAST(2.78 AS Decimal(5,2))
Regards
KP
|
|
|
|
|
Ah, time to post What Every Computer Scientist Should Know About Floating Point[^] again.
The value 2.78 cannot be stored exactly in a 32-bit floating point field. The closest approximation has the bit pattern 40 31 EB 85 (in hex), which is 1.011 0001 1110 1011 1000 0101 left-shifted by 1, i.e. 10.11 0001 1110 1011 1000 0101. (See IEEE 754[^] on Wikipedia.)
Converting to decimal you get:
1 * 2 ^ 1 = 2 + 2
0 * 2 ^ 0
1 * 2 ^ -1 = 0.5 + 2.5
1 * 2 ^ -2 = 0.25 + 2.75
0 * 2 ^ -3
0 * 2 ^ -4
0 * 2 ^ -5
1 * 2 ^ -6 = 0.015625 2.765625
1 * 2 ^ -7 = 0.0078125 2.7734375
1 * 2 ^ -8 = 0.00390625 2.77734375
1 * 2 ^ -9 = 0.001953125 2.779296875 You can see that the approximation is getting closer to 2.78, but the exact value is not possible as 0.03 (the residual after the first four bits) is not representable as a sum of negative powers of two. In the same way 1/3 is not representable exactly as a sum of negative powers of 10, or a decimal as we normally call it - the closest we can get is 0.33333 (and the 3s continue infinitely).
You can also see by the fact that the approximation is getting longer in decimal digits that a complete representation of the binary value will take a lot of space. I believe that a binary floating point value is always fully representable as a decimal (two dividing evenly into ten) but the space requirement may be unacceptable. Therefore, the value is almost always shown rounded to a certain number of places.
SQL Server does not have particularly good display-control features. That's not what it's for - it's for retrieving data efficiently. Instead you should use the typed-dataset mechanisms of whatever your client programming language or environment is - for example, the SqlDataReader in .NET - to retrieve the data without interpretation, then format the result using the programming language/environment's features (e.g. String.Format ).
If you want to preserve the decimals accurately, you should use one of the scaled integer data types (e.g. decimal which is a synonym for numeric ). These simply record the value without the decimal point, and a decimal exponent (e.g. here it would record 278 with an exponent of -2: 2.78 = 278 * 10 ^ -2).
|
|
|
|
|
5!
_______________________________________________________________________
http://www.readytogiveup.com/[ ^]
"you can't forget something you never knew..." M. Du Toit
|
|
|
|
|
5 for the best explanation ever.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Worth a 5 for the most comprehensive explanation ever put forward in the forums.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi.
What is a query that returns (for example) 5 records that a specified field is greater than otheres?
I have a table for news and this table has a numOfVisit field, now I want to return 5 most visited news.
(5 records that numOfVisit field is most greates)
Best wishes
|
|
|
|
|
select top 5 * from tablename order by numofvisit desc
gauthee
|
|
|
|
|
Use the TOP(xxx) command to limit returned values.
And the ORDER BY command to order these into the most visited.
For example
SELECT TOP(5) NewsID, NewsTitle, NewsText<br />
FROM NEWSTABLE<br />
ORDER BY numOfVisit ASC
You may need to use DESC instead of ASC depeding on which way round you want the results.
Any good?
|
|
|
|
|
Hi,
How do ranks work in full text searches? I don't understand? Must I go and setup ranks any where?
Regards,
ma se
|
|
|
|
|
CREATE PROCEDURE salary2
(
@projectid as int,
@months as tinyint,
@years as smallint,
@Insunday as smallint,
@Outsunday as smallint
)
As
declare
@countinstall as smallint
begin
select a.empid,b.empName,c.Whrs,c.Bassalary,c.hra,c.ca,c.ota,C.ot,c.Esi,c.srg,
case when (isnull(srg,0))=0 then @Outsunday else @Insunday end as days,c.Edate
from tblMonthHourDetails a,tblemployeemaster b,tblsalarydetails c where a.empid=b.empid and a.empid=c.empid and
b.projectid=@projectid and datepart(mm,[SDate])=@months and datepart(yy,[SDate])=@Years
group by a.empid,b.empName,c.Whrs,c.srg,c.Edate
end
GO
Hi in this stored procedure working...,
But The same tblsalarydeatils empid have more than one record...,
So i like to take the final entry record from that tblsalarydeatils empid based on the edate field...,
So, i have to use Order by desc method...,
The query should like this format(For example taken a paticular empid):
Select top 1 * from tblmonthsalarydetails where empid=608 order by edate desc
But see in my procedure i already used group by...,
So how to say in that, for the empid take latest record like?,
Means how to use there " order by edate desc"...,
Plz any one hlp me...,
Or give some solution for this probs,
Advance Thanks,
-- modified at 2:35 Monday 30th July, 2007
-- modified at 2:38 Monday 30th July, 2007
-- modified at 2:39 Monday 30th July, 2007
Regards,
Magi
|
|
|
|
|
After your group by clause just add order by clause.
i.e. select........ group by...... order by ... desc
gauthee
|
|
|
|
|
see if i use order by edate desc then which one have the highest date that record only displaying Others are not displaying ,
Regards,
Magi
|
|
|
|
|
Magi,
When you use group by the result would always be groupwise so that might be the reason it is howing date only for that group.
An alernative - create a view and write your query using group by then on the view you can use the top keyword and retrieve your records!
select top n * from view_name orderby column_name
gauthee
|
|
|
|
|
Hi what to value want to give in the n place...,
Plz understand my situation...,
See in that stored procedure...,
And give ur ideas...,
In that stored procedure i cant say n like...,
In that place i want to show some value...,
But that also after dispaly the records only i will get...,
Regards,
Magi
|
|
|
|
|
You said there would be more than one record with the same empno and you wnat the latest one, is there a field to identify the latest record of the two records?
gauthee
|
|
|
|