Showing posts with label operator. Show all posts
Showing posts with label operator. Show all posts

Monday, March 26, 2012

Invalid operator for data type. Operator equals boolean AND, type equals datetim

I am getting a error message saying: Invalid operator for data type. Operator equals boolean AND, type equals datetime.

I traced the pointer to @.gdo and @.gd, they are both dates!

INSERT INTO AdminAlerts values (CURRENT_USER, 'UPDATE', getDate(), @.biui, 'Updated booking, ID of booking updated: ' & @.biui & ', Booking date and time before/after update: ' & @.gdo & '/' & @.gd & ', Room number before/after update: ' & @.rno & '/' & @.rn & ' and Customer ID before/after update: ' & @.cio & '/' & @.ci)

If I cut that two dates out it works fine.
Could someone tell me the syntax to include a date in a string :confused:Another trouble, Now I also figure even I cancel the date variable out, I also get the Syntax error trying to convert varchar 'blah blah blah' into an int column.

INSERT INTO AdminAlerts values (CURRENT_USER, 'UPDATE', getDate(), @.biui, 'Updated booking, ID of booking updated: ' & @.biui & ', Booking date and time before/after update: ' & @.gdo & '/' & @.gd & ', Room number before/after update: ' & @.rno & '/' & @.rn & ' and Customer ID before/after update: ' & @.cio & '/' & @.ci)

I means the & @.biui & between Strings. @.biui, @.rno, @.rn are all int

Can someone give me some help pls?|||If I see it right you want to convert date and int into string. Try CAST or CONVERT, and use '+' to concatenate strings instead of '&' which is bitwise AND operation.|||Thanks!
It Works great!!

I have created a procedure which display all the record in a table.
How can I execute that in Access please? (I mean show the table in access)sql

Invalid operator for data type.

Kudos to y'all experts out there. I kinda needed your help. I'm trying to run a query...

SELECT a.AUF_POS AS Pos, c.ZL_STR AS Panel, a.POS_TEXT AS Description, a.BREITE AS W1, a.HOEHE

AS H1, a.BREITE2 AS W2, a.HOEHE2 AS H2, SUM(b.ANZ) AS Qty, SUM(b.LIEFER_ANZ) AS Dlvd,

SUM(b.RG_ANZ) AS Inv, (a.BREITE*a.HOEHE/CAST(1000000 AS NUMERIC)) AS UnitSQM,

(a.BREITE*a.HOEHE*SUM(b.ANZ)/CAST(1000000 AS NUMERIC)) as TotPosSQM

FROM liorder..LIORDER.AUF_POS a INNER JOIN liorder..LIORDER.AUF_STAT b ON a.AUF_NR = b.AUF_NR

AND a.AUF_POS = b.AUF_POS INNER JOIN liorder..LIORDER.AUF_TEXT c ON a.AUF_NR = c.AUF_NR AND

b.AUF_POS = c.AUF_POS

WHERE (c.ZL_MOD = 0) AND (b.AUF_NR = '86260')

GROUP BY a.AUF_POS, a.POS_TEXT, a.BREITE, a.BREITE2, a.HOEHE, a.HOEHE2, a.SFORM_NR, c.ZL_STR

...and I keep getting this error: Invalid operator for data type. Operator equals multiply, type equals nvarchar. I've tried every possible CAST and CONVERT but I just can't make it work. I'm pretty sure that the data types for the columns I mentioned on the mathematical equation are all numeric. Please help...Its going to be difficult for us to help without the DDL. Your query does alot of aggregrations (i.e. sum/avg/etc), thus you'd want to ensure that the column datatype is numeric.

Invalid operator for data type

What is wrong with this select statement?

SELECT lastName + ", " + firstName + " " + middleName as Name
FROM [users]
WHERE ([usrID] = 100)
I kept getting this error:

Msg 403, Level 16, State 1, Line 1
Invalid operator for data type. Operator equals add, type equals text.

Help is appreciated.

SELECT lastName + ', ' + firstName + ' ' + middleName as Name
FROM [users]
WHERE ([usrID] = 100)

|||Thanks! I tried that and got the same error.|||Please check your table definition for these columns. It seems that the data type for these columns cannot do the operation. If that is the case, change them to nvarchar(50) and then give it a try. I tested the code and it works.|||

mychucky:

What is wrong with this select statement?

Msg 403, Level 16, State 1, Line 1
Invalid operator for data type. Operator equals add, type equals text.

Take a look at the error message, it seems that your column(s) is defined to TEXT type, which can not be used with '+' operator. I agreed withlimno, you should change the data type to nvarchar if the column is not used to store large text. To manage TEXT data, you should use some functions. Take a look at 'Usingtext, ntext, and image Functions' topic in SQL2000 Books Online, or go to this link:

http://msdn.microsoft.com/library/en-us/acdata/ac_8_con_11_7zox.asp?frame=true

|||Many thanks for the help. Yes, I do have Text and varachar as thedatatype. So what is the best way to concatenate these columns?|||Change both data types to Varchar. Hope this helps.