Unix Technical Forum

Some Queries

This is a discussion on Some Queries within the SQL Server forums, part of the Microsoft SQL Server category; --> 1. In SQL Server 2000, even after using round function upto 2 decimals, the operation over a float field ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 06:25 AM
Sameer
 
Posts: n/a
Default Some Queries

1.
In SQL Server 2000, even after using round function upto 2 decimals,
the operation over a float field gives results upto 16 decimal places.
How can we avaoid this? Is it possible to display such results upto 2
decimal places in Query Analyzer? What are the related settings and
where to do it?

2.
My table 1 has 3 fields, table 2 has 5 fields.
Both tables have same records and a common field.
I want table 3 which will contain fields from both the tables and the
common field. How to achieve this?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 06:25 AM
Madhivanan
 
Posts: n/a
Default Re: Some Queries


1.
In SQL Server 2000, even after using round function upto 2 decimals,
the operation over a float field gives results upto 16 decimal places.
How can we avaoid this? Is it possible to display such results upto 2
decimal places in Query Analyzer? What are the related settings and
where to do it?

Look for Convert function in BOL

2.
My table 1 has 3 fields, table 2 has 5 fields.
Both tables have same records and a common field.
I want table 3 which will contain fields from both the tables and the
common field. How to achieve this?

Try this

Select * into Table3 from (Select T1.*, T2.field4, T2.Field5 from
Table1 T1, Table2 T2 where T1.CommonField=T2.CommonField) T

Madhivanan

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 06:26 AM
Erland Sommarskog
 
Posts: n/a
Default Re: Some Queries

Sameer (sameer75@gmail.com) writes:
> In SQL Server 2000, even after using round function upto 2 decimals,
> the operation over a float field gives results upto 16 decimal places.
> How can we avaoid this? Is it possible to display such results upto 2
> decimal places in Query Analyzer? What are the related settings and
> where to do it?


A float is an approxamite value, and is only exact by chance. A value
like 2.34 cannot be represented exactly in a float. If you only want to see
a certain number of decimals, use the decimal data type. Decimal are exact
numbers.

> 2.
> My table 1 has 3 fields, table 2 has 5 fields.
> Both tables have same records and a common field.
> I want table 3 which will contain fields from both the tables and the
> common field. How to achieve this?


Please post:

o CREATE TABLE statements for your tables.
o INSERT statement with sample data.
o The expected result given that sample.

The above sounds too strange to me, for wanting to try a guess.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:14 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com