473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Select boolean values merged in a text statement

Hi,

I have boolean values in a table for ex. Federation. And I want to
select following

Select 'Insert into' + member + 'test' as test1from federation

Then I get error message

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

Someone can help me out of it.

Thanks an advance

- Loi -
Jul 20 '05 #1
3 10528
On 1 Apr 2004 03:24:20 -0800, Loi Tan Vo wrote:
Hi,

I have boolean values in a table for ex. Federation.
No you don't, not in SQL Server. SQL Server doesn't have a boolean
datatype. I presume you meant to write that you have a column with
datatype bit?
And I want to
select following

Select 'Insert into' + member + 'test' as test1from federation

Then I get error message

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

Someone can help me out of it.

Thanks an advance

- Loi -


Without seeing your DDL, sample data and required output, it's hard to
tell what you want. However, the code you provided can be fixed by
* inserting a space between test1 and from
* using cast to convert the datatype from bit to character.

Sample repro (fixed):

use MyTestDB
go
create table federation
(member bit not null)
go
insert federation values(1)
insert federation values(0)
go
Select 'Insert into' + cast(member as char(1)) + 'test' as test1 from
federation
go
drop table federation
go

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Jul 20 '05 #2
> Select 'Insert into' + member + 'test' as test1from federation

Then I get error message

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


The error msg is saying that "member" of bit datatype cannot be
concatenated against the 2 strings. Cast it as varchar and you're
good to go:

Select 'Insert into ' + cast(member as varchar) + ' test' as test1
from federation

If you're trying to use dynamic SQL, suggest going to Erland
Sommarskog's site. He is the dynamic sql guru.
Jul 20 '05 #3
dwisott.

bit cant be added to a char. try casting it then adding it.

lo********@fnh.no (Loi Tan Vo) wrote in message news:<73**************************@posting.google. com>...
Hi,

I have boolean values in a table for ex. Federation. And I want to
select following

Select 'Insert into' + member + 'test' as test1from federation

Then I get error message

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

Someone can help me out of it.

Thanks an advance

- Loi -

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: MJunium | last post by:
I hope someone can help me with this one. For performance reasons, I have a denormalized database. There are two tables in the database we can call them table a and table b. Both of theses...
10
by: SueB | last post by:
I currently have a 'mail-merge' process in my Access db project. It generates custom filled out Award Certificates based on an SQL SELECT statement in a VBA routine invoked by clicking on a...
4
by: Jason Kumpf | last post by:
OK I've been staring at this code all day and still with everything I have tried I cannot figure out two problems I am having. Once is why the space limit for the directory I create in the code...
1
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
2
by: onetitfemme | last post by:
How come this works http://www.geocities.com/tekmonk2005/testSelectJS00.html works fine in Konqueror, but this http://www.geocities.com/tekmonk2005/testSelectJS02.html doesn't in FireFox,...
2
by: SFM | last post by:
I just want a simple datareader, that i can read the value returned from a select statement executed on a SQL server 2005 db. The code below should work in, but email= rdr.ToString(); when i...
3
by: =?Utf-8?B?TWlrZSBD?= | last post by:
I have a SQL 2000 table named IMSRejects with the fields: IMSRejects.ProductDescription IMSRejects.VendorName IMSRejects.CatalogNumber IMSRejects.ProductIMS2Desc IMSRejects.CMA8Desc Many of the...
6
by: dhek | last post by:
Hi, I have a very simple issue: for simplicity lets say I have 2 tables, A and B. - Table A contains 5 fields. Amongst these there is a 'id'-field which is but a reference to table B. - Table...
3
by: IntelliOfficer | last post by:
The data I am using was imported from Excel. The tables were then merged into one large table (3 million + records) and so cannot be re-exported into excel for modification. I am trying to map the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.