Solved

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

Posted on 2007-11-25
8
1,121 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
 
LVL 1

Author Comment

by:dshi15
ID: 20346135
I used declare @rowPro integer      in other store procedures,  it is fine, never has error.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now