Solved

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

Posted on 2007-11-25
8
1,168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

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.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

751 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