Showing posts with label procedures. Show all posts
Showing posts with label procedures. Show all posts

Tuesday, March 20, 2012

[Stored Procedures] How do I calculate 3^1.2?

Hello,

I am working with SQL Server 2005 stored procedures.

How do I do this:
SET @.MyAnswer = 3^1.2
--i.e. 3 to the 1.2 power

Currently it will not allow it because"The data types int and numeric are incompatible in the boolean XOR operator."

~Le

I think you must use FLOAT to use all or most of the mathematical functions and cast the result to Numeric. Hope this helps.

http://msdn2.microsoft.com/en-US/library/ms177516.aspx

|||

Caddre:

I think you must use FLOAT to use all or most of the mathematical function and cast the result to Numeric. Hope this helps.

http://msdn2.microsoft.com/en-US/library/ms177516.aspx

Excellent! That put me on the right path.

The correct function is:POWER(x,y)

and the key wasx.

Power (1.0000, 1) will return 1.0000
Power (1.00, 1) will return 1.00

Thanks!

`Le

Saturday, February 25, 2012

[Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure

I am new to SQL Server and stored procedures and here is my problem.

I am stepping into a stored procedure ‘storedProced1’ using T-SQL debugger. ‘storedProced1’ is calling ‘storedProced2’. When I step into the following line where storedProced2’ is being executed,

exec storedProced2 @.Parameter1, @. Parameter2, @. Parameter3

I got the following message in the immediate window.

[Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'storedProced2’.

@.RETURN_VALUE = N/A

But “storedProced2” does exists. What am I doing wrong?

Make sure that the procedure exists within the actual database and make sure that you are using the right owner declaration for this, this calling the procedure with the Routine_Schema and Routine_Name from the following query.

SELECT Routine_schema, ROutine_name
From INFORMATION_SCHEMA.Routines
WHere Routine_Name = 'storedProced2'

--> Calling EXEC <SchemaName>.<Objectname>

HTH, jens K. Suessmeyer.

http://www.sqlserver2005.de

Saturday, February 11, 2012

@original and stored procedures

When using @.original_{0}, how does this work if you are using a stored procedure instead of inline SQL? For example, if my update parameters are like this :

<

UpdateParameters><asp:ParameterType="String"Name="ProductType"/><asp:ParameterType="String"Name="OpportunityType"/><asp:ParameterType="Double"Name="Value"/><asp:ParameterType="String"Name="Probability"/><asp:ParameterType="Int32"Name="OpportunityID"/></UpdateParameters>

And my stored procedure like this :

CREATE procedure dbo.UpdateOpportunity

(
@.ProductType int,
@.OpportunityType int,
@.Value money,
@.Probability int,
@.OpportunityID int
)

as

update Opportunity
set ProductType = @.ProductType, OpportunityType = @.OpportunityType,
[Value] = @.Value, Probability = @.Probability
where OpportunityID = @.OpportunityID

Do I need to change both cases of @.OpportunityID in my stored procedure to @.original_OpportunityID for it to work?

Most likely. It also depends on what you have set for the conflictdetection property. If it's compareallvalues, then you'll need to accept @.original_ for each of the columns that you selected via your select statement.