I'm trying to return multiple column, one of which is a column + a comma delimitted list of values. Below is a simplified, non working, query:
(assume @MyBit, @MyVarChar, and @MyValue are all declared)
SELECT distinct
IsNull(Column1, '') AS Column1,
IsNull(Column2,'') + CASE WHEN @MyBit = 1 THEN ' My Test: ' + (select @MyVarChar = COALESCE(Column3 + ', ', '') from TableSub where Value = @MyValue) ELSE '' END AS Column2,
FROM TableMain
I get an ADO error: Incorrect syntax near '='
Thoughts?
Thanks
3 3960
(select @MyVarChar = COALESCE(Column3 + ', ', '') from TableSub where Value = @MyValue)
use "[ ]" brackets instead of "( )" around the above select statment.
(and remove the last comma before the FROM stmnt)
I now have:
SELECT distinct
IsNull(Column1, '') AS Column1,
IsNull(Column2,'') + CASE WHEN @MyBit = 1 THEN ' My Test: ' + [select @MyVarChar = COALESCE(Column3 + ', ', '') from TableSub where Value = @MyValue] ELSE '' END AS Column2
FROM TableMain
and I get:
ADO error: Invalid column name 'select @MyVarChar = COALESCE(Column3 + ',', '') from TableSub where Value = @MyValue'
Thanks
my apologies - here is the correct query
SELECT distinct
IsNull(Column1, '') AS Column1,
IsNull(Column2,'') + CASE WHEN @MyBit = 1 THEN ' My Test: ' + (select COALESCE(Column3 + ', ', '') from TableSub where Value = @MyValue) ELSE '' END AS Column2
FROM TableMain
put the "( )" back on and remove the @MyVarChar = (that is where the err is)
you just need select coalesce...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alberto Vera |
last post by:
Hello:
I have the next structure:
How Can I make it using Python?
How Can I update the value of 6?
|
by: Paul Davis |
last post by:
I'd like to overload 'comma' to define a concatenation operator for
integer-like classes. I've got some first ideas, but I'd appreciate a
sanity check. The concatenation operator needs to so...
|
by: Jeff Roughgarden |
last post by:
I am using a clever product called SQL Expert Pro to optimize
problematic SQL statements. It works by generating syntactically
identical variations of the original SQL, finding all unique execution...
|
by: Craig Keightley |
last post by:
I have a mysql database with a list of companies who supply specific
products
tblSuppliers (simplified)
sID | sName | goodsRefs
1 | comp name | 1,2,3,4,5
2 | company 2 | 2,4
|
by: Steffen Vulpius |
last post by:
Hi everybody,
VARCHAR has a higher precedence than CHAR. If you have a query
SELECT COALESCE(c1,c2) FROM T1
where c1 is CHAR(5) and c2 is VARCHAR(10), I would expect the return
type to be...
|
by: Simon Windsor |
last post by:
Hi
Is there a standard postgres method of replacing empty strings.
In Oracle, nvl handles nulls and empty strings, as does ifnull() in
MySQL, but with postgres coalesce only handles null...
|
by: therealtigger |
last post by:
i know I'm going mad. I did this just a couple of weeks ago, now I can't get anything in the export window to let me send query results as a comma delimited txt file. I'm new to access but i thought...
|
by: r035198x |
last post by:
This is a short tip describing the sql coalesce function.
Description
COALESCE accepts a comma separated list of parameters and returns
the first value that is not null in that list or null...
|
by: hansoffate |
last post by:
Hi,
The first part of my script works fine. Basically, the script reads a file with IDs that I want to search from a Flatdatabase and pull information. I setup the a TILDA Delimitted File...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
|
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...
| |