SQL Server 2000: Invalid operator for data type. Operator equals add, type equals ntext - sql-server-2000

I have a stored procedure which gets Ntext parameters. Inside the stored procedure, I have a varchar variable and I set this varchar variable by concatenating few strings.
I get the following error at this point, while compiling.
Invalid operator for data type. Operator equals add, type
equals ntext.
Can someone help?

I made a careless Mistake. I was actually concatenation my varchar variable with the ntext variable. As Ntext concatenation is not allowed, I got stuck.

Related

Explicitly convert datetime to varbinary

I am attempting to convert a datetime column to varbinary(100), but haven't had any luck. My problem is very similar to Convert datetime to varbinary inside update query, but I still wasn't able to develop a solution.
Here is my code:
OPEN SYMMETRIC KEY SymKey_TheDate_SYMMETRIC
DECRYPTION BY CERTIFICATE Certificate_TheDate_Encryption
UPDATE PROFILE_DATA
SET A29_FDATE = EncryptByKey (Key_GUID('SymKey_TheDate_SYMMETRIC'), CONVERT(varbinary(100), A29_FDATE))
FROM PROFILE_DATA
GO
CLOSE SYMMETRIC KEY SymKey_TheDate_SYMMETRIC
Here is the error I get when trying to convert A29_FDATE from datetime to varbinary(100):
Implicit conversion from data type varbinary to datetime2 is not allowed. Use the CONVERT function to run this query.
Your error is not for datetime to varbinary(100), but for varbinary to datetime2. The function EncryptByKey() returns a varbinary that is assigned to a date field A29_FDATE. The output of EncryptByKey() needs explicit conversion if you are going to attempt it.
Something like:
...
SET A29_FDATE = convert(datetime2(0), EncryptByKey(...))
...
Re-read your error:
Implicit conversion from data type varbinary to datetime2 is not allowed. Use the CONVERT function to run this query.
You get a varbinary value just fine. The error is converting it to datetime2. The statement is converting it to datetime2 when it tries to set the field 'A29_FDATE` to the varbinary value. I assume from the field name it is a datetime2 field. I don't think you can or should convert this to a datetime2 field.
If you are in the process of encrypting the field in your table, you will have to create a new column with the type varbinary, probably A29_FVARBIN (yuck), and update that to the result of your query. Then you can drop the A29_FDATE field if you want.

[Excel Destination [28]] Error: An error occurred while setting up a binding for the column. The binding status was "DT_NTEXT"

I'm working on ssis package which exports data from SQL Server to Excel. I had a problem converting non-unicode to unicode string data types. So I created a derived Column task and converted to Unicode string [DT_WSTR] 4 columns which have a type Varchar(40) in SQL Server table. It worked with these columns. But I also have a Description column of type varchar(max) and I tried to convert it to Unicode text stream [DT_NTEXT]. It did not work.
If your source is SQL Server (as you said), you can convert it directly in your SQL Query
SELECT
CONVERT(NVARCHAR(40), 'att1')
,CONVERT(NTEXT, 'att2')
Convert your VARCHAR into NVARCHAR
Convert your TEXT into NTEXT
it's faster.
P.S. To test it (Do not forget to delete or reset your previous OLE DB Input component) -> It will be forced to reevaluate your datatype
Does it help you?
The only thing that worked was to cast a Description column in Stored Procedure as varchar(1000). I checked the max length of this field and it was about 300 characters. So I made it varchar(1000) and in Derived column Unicode string [DT_WSTR]. This was a workaround, but I still want to know how to make it in ssis package without converting data type in Stored Procedure.

SSIS Can't Store Decimal Output Into Variable (Execute SQL Task)

For the life of me I can't figure out how to store a decimal from a Stored Procedure into an SSIS Variable.
I have an Execute SQL Task that returns a result set. I mapped the column to the variable. I keep getting "Input string was not in a correct format". If I'm returning a decimal from my stored procedure and have the variable type as decimal. I would think this would work, but it doesn't.
Other things I've tried...
- Cast the column as a float and use variable double.
- Cast the column as a varchar and use variable string (succeeded but didn't store value)
- I've done variations on using Output instead of resultset but basically same issues.
Any ideas on how I can get this to work?
Thanks in advance!
As requested here are some screenshots:
This shows the assignment to the variable.
This is showing the variable as a decimal type.
This is showing the error received.
I didn't include the stored procedure but it defines vPreviousValue as a decimal(18,4) and returns it in the result set.
In case it may be helpful to someone else in the future...
After trying many variations I was able to figure out how to make this work.
I had the stored procedure output into a 'double' parameter.
I also found this link useful: http://milambda.blogspot.com/2014/02/sql-server-integration-services-data.html

SQL converting nvchar to ntext

What I have is a staging table that is all nvarchar (so i can load it easily). In my live table i have a bunch of ntext items. I have the following:
obviously this isnt the whole query:
update
SLTDS_C69_Stdtable
set
[AARIssue] = convert(ntext, st.[AARIssue]),
[AttachmentIDs] = convert (ntext, st.[AttachmentIDs])
I get this error returned:
types ntext and nvarchar are incompatible in the equal to operator.
ANy idea how to fix this?
Do you want to replace the text or add to it?
INthe first case you don't need to convert at all, just set the filed to the value of the filed inthe other table. INthe second case you need to use UPDATE text.
However, you have a problem in that ntext is deprecated, you should consider converting these fields to nvarchar(max) as soon as possible unless you are still running SQL Server 2000.
Is this a repeat of this: How to update a text or ntext field in SQL Server 2000
The live table should use UPDATETEXT?

Data Type Mapping

I need to store XML data to database(MS SQL Server). The data type defined in the column is text.
I need to know the the equalent datatype for text. I have tried with adLongVarChar but it does not works. Also I tried with adLongVarWChar(nText). But both are not working.
Need help.
Thanks.
In case your are using SQL Server 2005 or higher then you might prefer going for the XML data type. Read more of it here http://www.codeproject.com/KB/database/XMLdDataType.aspx
Also going forward avoid using ntext and text data types as they would be removed from future versions of SQL Server. Instead go for nvarchar(max) or varchar(max). Read on this here http://msdn.microsoft.com/en-us/library/ms187993.aspx
cheers
TSQL datatype for a string is varchar or nvarchar (unicode). To specify the length of the string, varchar(50).
Also note there is an XML datatype in SS 2008 (2005?).