Wednesday, March 28, 2012
How to force SQL Server to handle all numeric types as doubles?
doubles? Eg. I have an very simple query:
SELECT 1+1 AS Result
I need SQL Server to work with number 1 as with double and also to return a
result as a double (however it doesn't make any sence in this situation).
Thanks.Hi
I don't think there is an automatic way, but you can use the CAST/CONVERT
functions. Also check out the topic "Data Type Precedence" in Books Online.
John
"Tomas Machala" <t.machala@.tiscali.cz> wrote in message
news:%23X$A60tDGHA.3988@.TK2MSFTNGP12.phx.gbl...
> Hi, is it possible to force SQL Server to handle all numeric data types as
> doubles? Eg. I have an very simple query:
> SELECT 1+1 AS Result
> I need SQL Server to work with number 1 as with double and also to return
> a result as a double (however it doesn't make any sence in this
> situation).
> Thanks.
>|||Tomas Machala (t.machala@.tiscali.cz) writes:
> Hi, is it possible to force SQL Server to handle all numeric data types as
> doubles? Eg. I have an very simple query:
> SELECT 1+1 AS Result
> I need SQL Server to work with number 1 as with double and also to
> return a result as a double (however it doesn't make any sence in this
> situation).
The one way, is to express the numbers as floats. So in your example:
SELECT 1E0+1E0 AS Result
Note that in an expression like:
SELECT 1E0 + 1 Result
The integer one will be automatically converted to float.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx
Monday, March 26, 2012
How to fix DT_Text and DT_NText Read Only in Script Component
I have a script component that I have written and works as long as the Output columns on the script are string types. When I change the output column type to text (since the size could be essentially unlimited) it gives an error in the script component that the property is read only.
Here is the code line that fails with Property Payments is read only.
Output0Buffer.Payments = fieldValues(i)
If I change the column payments to DT_Wstr it works without issue, but I want to use text incase the value is large.
Here is the error if you try to run the actual script even though I know it has an error.
TITLE: Package Validation Error
Package Validation Error
ADDITIONAL INFORMATION:
Error at Data Flow Task [Script Component [85]]: Error 30526: Property 'Payments' is 'ReadOnly'.
Line 86 Column 13 through 69
Error 30526: Property 'Ops' is 'ReadOnly'.
Line 155 Column 13 through 65
Error at Data Flow Task [Script Component [85]]: Error 30526: Property 'Payments' is 'ReadOnly'.
Line 86 Column 13 through 69
Error 30526: Property 'Ops' is 'ReadOnly'.
Line 155 Column 13 through 65
Error at Data Flow Task [DTS.Pipeline]: "component "Script Component" (85)" failed validation and returned validation status "VS_ISBROKEN".
Error at Data Flow Task [DTS.Pipeline]: One or more component failed validation.
Error at Data Flow Task: There were errors during task validation.
(Microsoft.DataTransformationServices.VsIntegration)
BUTTONS:
OK
Try explicitly calling SetString() on the column. Any better?
Thanks
Mark
The reason it doesn't work is that Blob data types have a different interface in pipline script components.
Then, to set to value to a text field (DT_TEXT or DT_NTEXT) in a pipeline script component, use AddBlobData(), as in:
Imports System.Text
...
Output0Buffer.Payments.AddBlobData(Encoding.Unicode.GetBytes(SomeStringHere))|||I had just figured it out before this post.. but my code was way worse... yours works well and is clean. Thanks!