July 7, 2009 at 2:35 pm
Can anyone tell me what is the right way to code the following. Simply, when I do the insert without the where clause, its works. I add the where clause and i get the following error... thanks
------------------
An expression of non-boolean type specified in a context where a condition is expected, near 'description'.
------------------
SET @SEQ = 'insert into #TABLE_DATA (field_data) '
SET @SEQ = @SEQ + ' (SELECT TOP 4 '
SET @SEQ = @SEQ + ' description '
SET @SEQ = @SEQ + ' FROM '
SET @SEQ = @SEQ + ' sugarcrm.accounts '
SET @SEQ = @SEQ + ' where description is not null )' -- this line creates the error....
exec (@SEQ)
July 7, 2009 at 5:22 pm
shadigirgis (7/7/2009)
Can anyone tell me what is the right way to code the following. Simply, when I do the insert without the where clause, its works. I add the where clause and i get the following error... thanks------------------
An expression of non-boolean type specified in a context where a condition is expected, near 'description'.
------------------
SET @SEQ = 'insert into #TABLE_DATA (field_data) '
SET @SEQ = @SEQ + ' (SELECT TOP 4 '
SET @SEQ = @SEQ + ' description '
SET @SEQ = @SEQ + ' FROM '
SET @SEQ = @SEQ + ' sugarcrm.accounts '
SET @SEQ = @SEQ + ' where description is not null )' -- this line creates the error....
exec (@SEQ)
You know, the people that help out here are all un-paid volunteers. Providing the DDL scripts (CREATE TABLE, CREATE INDEX, etc.) for the tables affected, and INSERT statements to put some test data into those tables that shows your problem will go a long way in getting people to look at your issue and help you out. For your problem, please include the INSERT INTO scripts for the first 4 rows from sugarcrm.accounts where description is not null. Please include code for what you have already tried. If you help us with this information, we'll be able to help you with your problem a lot easier.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
July 7, 2009 at 6:28 pm
Here are the declerations that i use...
*********************************
IF EXISTS (SELECT ID FROM TEMPDB.DBO.SYSOBJECTS WHERE ID = OBJECT_ID('TEMPDB.DBO.#TABLE_DATA'))
DROP TABLE #TABLE_DATA
CREATE TABLE #TABLE_DATA (
FIELD_DATA varchar(1000) )
DECLARE @SEQ VARCHAR(100)
July 7, 2009 at 6:38 pm
Replace exec(@SEQ) with
PRINT @SEQ
-- exec (@SEQ) -- uncomment when it's debugged
Helps a lot.
_____________
Code for TallyGenerator
July 7, 2009 at 6:58 pm
You are amazing :-)!!!!!!!!!!!!!!!!!!!!! Thanks!
I can't believe the error I had. My @SEQ was only varchar(100) and so it was getting cut off after the word description in my where clause...
I changed the size and it's fixed 🙂 I spent so many hours...
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply