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
 General SQL Server Forums
 New to SQL Server Programming
 Urgent help required with '^' operator

Author  Topic 

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2012-09-25 : 04:59:25
Hi All,
I am getting this error when this query is executed:
The data types numeric and int are incompatible in the '^' operator.

query is:
select 13.2846176*(10/5)^4 -24.27436623*(20/5)^3 + 14.27967309*(30/5)^2 + -2.455442334*(40/5) + 0.114953113

Please help.

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2012-09-25 : 05:28:50
'^' Denotes XOR operator in T-sql, you have to use Power() function


select power(13.2846176*(10/5),4 )- power(24.27436623*(20/5),3) + power(14.27967309*(30/5),2) + -2.455442334*(40/5) + 0.114953113

Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2012-09-25 : 05:39:30
quote:
Originally posted by senthil_nagore

'^' Denotes XOR operator in T-sql, you have to use Power() function


select power(13.2846176*(10/5),4 )- power(24.27436623*(20/5),3) + power(14.27967309*(30/5),2) + -2.455442334*(40/5) + 0.114953113

Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008




Thanks a lot for the help.
I have run the query with some additions to it,but i get error
"max functions requires on argument"
query is:
select min(max(power(13.2846176*(10/5),4 )- power(24.27436623*(20/5),3) + power(14.27967309*(30/5),2) + -2.455442334*(40/5) + 0.114953113,0),1))

please help please.
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2012-09-25 : 05:55:25
What you tring to achieve it? min/max requires only one expression..

Check this

http://msdn.microsoft.com/en-us/library/ms187751.aspx

Senthil Kumar C
------------------------------------------------------
MCITP - Database Administration SQL SERVER 2008
MCTS - Database Development SQL SERVER 2008
Go to Top of Page
   

- Advertisement -