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 2000 Forums
 SQL Server Development (2000)
 FORMAT function in SQL server

Author  Topic 

jennypretty
Yak Posting Veteran

96 Posts

Posted - 2004-10-13 : 10:33:41
Hello friends,
I have this query in Access:
select emp_num,
total_salary,
max_salary,
Format(total_salary/max_salary) AS percent_sal, (line 4)
Format(total_salary*.25)/max_salary AS bonus_sal (line 5)
From emp;

When I create this as an SQL View, I keep everything the same. it generate errors at line 4 & 5.
Line4: 'Format' is not a recognized function name.
Line5: 'Incorrect syntax near 'total_salary'

Can you please help.
Thanks.




The stupid question is the question you don't ask.
www.single123.com

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-10-13 : 10:38:48
you have your answer...
Line4: 'Format' is not a recognized function name.

for a percent, I don't know of a function to 'format' it,

i believe for money you can do '$'+convert(varchar,convert(money,total_salary*.25),1)

Corey
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-10-13 : 10:43:59
Format(ting) is a presentation function....and should be in your front end....
Access mixed DB + FrontEnd code/functionality in together...
SQL deals best with DB only.

However....have a look at the CAST and CONVERT functions.
Go to Top of Page

jennypretty
Yak Posting Veteran

96 Posts

Posted - 2004-10-13 : 11:16:11
It doesn't work.
Don't know why.
Errors: 'Incorrect sysntax near '('

The stupid question is the question you don't ask.
www.single123.com
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-10-13 : 11:22:43
show us the whole statement.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-10-13 : 22:12:51
your access query lacks some parameters for format.

what format do you need for line4 and line5?

check convert or cast (as was advised) in BOL, this comes with your sql server. click start button>program files>microsoft sql server>books on line

it covers all basic questions that would give you a good start in learning tsql.

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -