Solved

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

Posted on 2007-11-25
8
1,153 Views
Last Modified: 2010-04-21
ALTER Procedure [dbo].[sp_ProcessImage]

      @Err int OUTPUT
      
As
declare @rowPro integer      -- 1 row must be Updated

select @Err = 1
      
Begin Tran

INSERT INTO Asset
( ............


It has error in line

select @Err = 1

said
Invalid operator for data type. Operator equals boolean AND, type equals varchar.

Why?

thanks.
0
Comment
Question by:dshi15
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20346051
can u post the complete query
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20346086
I believe that the actual error is on the previous line. There is no "integer" data type in SQL Server. Change the line to:

declare @rowPro int
0
 
LVL 1

Author Comment

by:dshi15
ID: 20346125
ALTER Procedure [dbo].[sp_maint_ProcessImageLibrary]
      
      @Err int OUTPUT
      
As
declare @rowPro integer      -- 1 row must be Updated

                                                
select @Err = 1      
Begin Tran

INSERT INTO Asset
(
AssetId,
DownloadPath,
PreviewPath,
FSPath,
ToDate,
AssetDesc,
AssetType,
DownloadFile,
PreviewFile,
FSFile,
GraphicColor,
AllPromos,
AllTG,
AllBrands,
Status,
FromDate,
SystemDate,
UID
)
SELECT 'test_' & [OfferGraphics].[AssetName] AS Expr1,
'https://DOCUMENTS.com/W/' & 'TakeLoadOff' & '/' AS Expr2,
'https://DOCUMENTS.com/W/' & 'TakeLoadOff' & '/Thumbnail/' AS Expr3,
'https://DOCUMENTS.com/W/' & 'TakeLoadOff' & '/Large/' AS Expr4,
'9/15/2007',
OfferGraphics.[AssetDescription],
6,
OfferGraphics.[DownloadFileName],
OfferGraphics.[PreviewFilename],
OfferGraphics.[FSFileName],
OfferGraphics.[BW/Color],
'N',
'N',
'N',
'A',
getdate(),
getdate(),
'011sh'
FROM OfferGraphics

      select @rowPro = @@rowcount
      
if @rowPro <> 1 or @@error != 0
      begin
            Rollback Tran
            select @Err = 1
            return
      end
Commit Tran
      select @Err = 0      
      return
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:dshi15
ID: 20346135
I used declare @rowPro integer      in other store procedures,  it is fine, never has error.
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 20346137
In order to perform string addition use '+'
ALTER Procedure [dbo].[sp_maint_ProcessImageLibrary]
      
      @Err int OUTPUT
      
As
declare @rowPro integer      -- 1 row must be Updated
 
                                                
select @Err = 1      
Begin Tran
 
INSERT INTO Asset
(
AssetId,
DownloadPath,
PreviewPath,
FSPath,
ToDate,
AssetDesc,
AssetType,
DownloadFile,
PreviewFile,
FSFile,
GraphicColor,
AllPromos,
AllTG,
AllBrands,
Status,
FromDate,
SystemDate,
UID
)
SELECT 'test_' + [OfferGraphics].[AssetName] ,
'https://DOCUMENTS.com/W/' + 'TakeLoadOff' + '/',
'https://DOCUMENTS.com/W/' + 'TakeLoadOff' + '/Thumbnail/' ,
'https://DOCUMENTS.com/W/' + 'TakeLoadOff' + '/Large/' ,
'9/15/2007',
OfferGraphics.[AssetDescription],
6,
OfferGraphics.[DownloadFileName],
OfferGraphics.[PreviewFilename],
OfferGraphics.[FSFileName],
OfferGraphics.[BW/Color],
'N',
'N',
'N',
'A',
getdate(),
getdate(),
'011sh'
FROM OfferGraphics
 
      select @rowPro = @@rowcount
      
if @rowPro <> 1 or @@error != 0
      begin
            Rollback Tran
            select @Err = 1
            return
      end
Commit Tran
      select @Err = 0      
      return

Open in new window

0
 
LVL 1

Author Closing Comment

by:dshi15
ID: 31410856
thank you very much.
0
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 20346169
TSQL is not VB.  No *integer* data  type nor *&* operator.  Use *int* and *+* instead...
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 20346261
I suppose that "integer" is some not very well documented alias for "int". You should stick with the normal names for the data types, the ones that everyone else are using.

Also, the != operator is non-standard. You should use the <> operator instead.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question