Solved

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

Posted on 2007-11-25
8
1,161 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Conditions in Where clause 9 46
SqlServer Table Triggers 3 28
removing rows from sql result set  where some column values are repeated 1 23
Need help with a query 14 32
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.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

679 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