Click here to Skip to main content
15,881,173 members
Home / Discussions / Database
   

Database

 
GeneralRe: how to return primary key when insert statement violates unique constraint Pin
Richard.Berry10012-May-14 7:55
Richard.Berry10012-May-14 7:55 
GeneralRe: how to return primary key when insert statement violates unique constraint Pin
Eddy Vluggen12-May-14 8:49
professionalEddy Vluggen12-May-14 8:49 
GeneralRe: how to return primary key when insert statement violates unique constraint Pin
Corporal Agarn12-May-14 9:45
professionalCorporal Agarn12-May-14 9:45 
GeneralRe: how to return primary key when insert statement violates unique constraint Pin
jschell12-May-14 10:31
jschell12-May-14 10:31 
AnswerRe: how to return primary key when insert statement violates unique constraint Pin
Mycroft Holmes12-May-14 22:25
professionalMycroft Holmes12-May-14 22:25 
AnswerRe: how to return primary key when insert statement violates unique constraint Pin
Nico Haegens13-May-14 2:18
professionalNico Haegens13-May-14 2:18 
GeneralRe: how to return primary key when insert statement violates unique constraint Pin
Mycroft Holmes13-May-14 12:52
professionalMycroft Holmes13-May-14 12:52 
QuestionDatabase SQL Pin
Syafiqah Zahirah10-May-14 4:47
Syafiqah Zahirah10-May-14 4:47 
AnswerRe: Database SQL Pin
Peter Leow10-May-14 5:24
professionalPeter Leow10-May-14 5:24 
GeneralRe: Database SQL Pin
Syafiqah Zahirah11-May-14 3:43
Syafiqah Zahirah11-May-14 3:43 
AnswerRe: Database SQL Pin
Peter Leow11-May-14 4:13
professionalPeter Leow11-May-14 4:13 
GeneralRe: Database SQL Pin
Syafiqah Zahirah11-May-14 4:45
Syafiqah Zahirah11-May-14 4:45 
GeneralRe: Database SQL Pin
Syafiqah Zahirah15-May-14 6:50
Syafiqah Zahirah15-May-14 6:50 
GeneralRe: Database SQL Pin
Peter Leow15-May-14 14:47
professionalPeter Leow15-May-14 14:47 
QuestionArithmetic rounding Pin
Richard.Berry1009-May-14 11:04
Richard.Berry1009-May-14 11:04 
Hi
I need to multiply two columns (float) each of which can have a max of 4 decimal places and round the result to 3 decimal places.

It seems the ROUND(val,decimal_places) uses bankers rounding? (SQL Sever 2008R2) - Although I have read it uses Symmetric Arithmetic Rounding?

Doing the same calculation in Excel gives me the result I need, but Excel uses normal Arithmetic rounding.

How can I do a query to use arithmetic rounding (like Excel)

Examples of the errors:

C#
Price	Qty	Val	ExcelRound	SQLRound
7.5169	745	5600.0905	5600.091	5600.090
4.3465	463	2012.4295	2012.430	2012.429
1.6401	125	205.0125	205.013	205.012
0.0395	369	14.5755	14.576	14.575
5.2349	955	4999.3295	4999.330	4999.329
9.0285	141	1273.0185	1273.019	1273.018
9.0899	645	5862.9855	5862.986	5862.985
3.6167	215	777.5905	777.591	777.590
3.1145	135	420.4575	420.458	420.457
7.4115	105	778.2075	778.208	778.207
7.8675	313	2462.5275	2462.528	2462.527
8.8405	227	2006.7935	2006.794	2006.793
5.4269	55	298.4795	298.480	298.479
1.8833	445	838.0685	838.069	838.068
9.7349	655	6376.3595	6376.360	6376.359
8.6487	365	3156.7755	3156.776	3156.775
1.9033	125	237.9125	237.913	237.912
4.8197	545	2626.7365	2626.737	2626.736


PS: how do you post a table with nicely formatted columns?

modified 9-May-14 17:33pm.

AnswerRe: Arithmetic rounding Pin
Richard Andrew x649-May-14 12:26
professionalRichard Andrew x649-May-14 12:26 
GeneralRe: Arithmetic rounding Pin
Richard.Berry1009-May-14 20:58
Richard.Berry1009-May-14 20:58 
AnswerRe: Arithmetic rounding Pin
Andrius Leonavicius9-May-14 15:02
professionalAndrius Leonavicius9-May-14 15:02 
GeneralRe: Arithmetic rounding Pin
Richard.Berry1009-May-14 20:45
Richard.Berry1009-May-14 20:45 
GeneralRe: Arithmetic rounding Pin
Andrius Leonavicius10-May-14 4:28
professionalAndrius Leonavicius10-May-14 4:28 
QuestionFetch records efficiently Pin
avi_dadi20029-May-14 9:15
avi_dadi20029-May-14 9:15 
AnswerRe: Fetch records efficiently Pin
Richard Andrew x649-May-14 10:30
professionalRichard Andrew x649-May-14 10:30 
AnswerRe: Fetch records efficiently Pin
Richard MacCutchan9-May-14 21:49
mveRichard MacCutchan9-May-14 21:49 
QuestionNeed to fetch from two data sources Pin
avi_dadi20029-May-14 9:11
avi_dadi20029-May-14 9:11 
AnswerRe: Need to fetch from two data sources Pin
Richard.Berry1009-May-14 21:40
Richard.Berry1009-May-14 21:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.