i want to do something like this;
for-example;
Set vote = true for all rows in tbl_emp where pk_tbl is in the comma separated value list. - update tbl_emp
-
set vote=true where pk_tbl in @empl_vote_true
-
Where, @empl_vote_true = ’12,23,345,’ (IDs of the employees),
Is it possible, if so how?
9 8822
Hi Yarsirzafar
The IN Clause within WHERE should be enclosed in Parentheses i.e IN(6,45,233);
Try that
Kind regards
You can't do it that way. Not even if you put it in parentheses because the variable will always be a string. The IN clause will never see it as more than one value.
Unless you know the string will always contain the same number of items, you will have to build a dynamic string and then execute that.
If you really need to, you can convert that string into a result set so you can use IN clause.
Here, read this...
Good Luck!!!
~~ CK
As an update on my previous answer I will make the following assumptions;
Column 'vote' is type yes/no; true/false
column 'pk_tbl' is type integer
@empl_vote_true = "12,23,345"
sql= "UPDATE tbl_emp SET " _
& "vote = true " _
& "WHERE pk_tbl IN('" & @empl_vote_true & "');
Make sure you have the single and double quotes correct
This performs OK in Access 2007
Kind regards
thanks for your answer, if that set is passed to a Stored procedure, via a variable whose datatype is string in c#, and varchar(8000) in sql server - string empl_vote_true = ",12,13,14,15,16"
Then at this stage, - sql= "UPDATE tbl_emp SET " _
-
& "vote = true " _
-
& "WHERE pk_tbl IN('" & @empl_vote_true & "')
will it work fine? or something should be added or parsed before. would i need a loop to update for each where clause, thanks
I don't do c#, but it should work in MS SQLserver
Hi Yasirzafar
When I looked at your code again the line
string empl_vote_true = ",12,13,14,15,16"
You should not have an opening comma without data it will throw an error.
Kind regards
you mean, the string should be in the form of "12,13,14,15,16";
(for clarification). And it will work?
The only way is to try it.
Kind regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Craig Keightley |
last post by:
I can do the match perfectly but what i also need to do is create a third
list of comma separated values that are in both
eg:
List 1 => 1,2,3,4,5,6,7,8,11
List 2 => 1,3,4,5,6,7,10,23
...
|
by: Bob |
last post by:
I think this is very simple but I am having difficult doing it. Basically
take a comma separated list:
abc, def, ghi, jk
A list with only one token does not have any commas:
abc
The first...
|
by: starman7 |
last post by:
I'm attempting a query that gathers product data for a particular
product id.
One of the items is designer(s) which can be more than one.
The product table has comma separated id's of the...
|
by: mahe23 |
last post by:
All,
How do One convert a comma separated column from a text file into rows in oracle. I have a scenario where the list of comma separated values changes dynamically.
It is like:
abc, ttt,...
|
by: Nishanth |
last post by:
I want to know how to validate a string which is comma separated
"C1","2","12344","Mr","John","Chan","05/07/1976".........
I need to validate each field value against a set of rules, for...
|
by: MMcCarthy |
last post by:
This is a module that imports information to a Query or a Table from comma separated values file in a text format! It is very helpful for getting information from other applications and from files!
...
|
by: hirak1984 |
last post by:
Dear Sir/mam,
I am new comers for DB2 .I Write a Stored Procedure below in line
CREATE PROCEDURE AUS.PROCEDURE1 ( IN var0 VarCHAR(4000),
OUT var1 CHAR(6) )
DYNAMIC RESULT SETS 1...
|
by: alister joseph |
last post by:
hi
I have two tables, i have to combine them & a column should contain comma separated value.
example
1 a
2 b
2 c
2 d
3 a
|
by: Hermann |
last post by:
I run a server with apache 1.3 and php 5.
Yesterday I notice that sometimes the HTTP_HOST server variable has a
comma separated list in it.
Let's say my domain name is: www.mydomain.com
Usually...
|
by: rythmik1 |
last post by:
I need to create an alphabetized list from multiple rows that contain comma separated tags.
Example:
Row1 -> Lessons, Discussions, Help
Row2 -> Discussions, Chat
Row3 -> Surveys,...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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: 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...
|
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...
| |