Hi All,
i hv created a sp as
Create proc P @iClientid varchar (100)
as
Begin
select * from clients where CONVERT(VACHAR( 100),iClientid) in(
@iclientid)
end
where iclientid = int data type in the clients table.
now if i pass @iclientid as @iclientid = '49,12,112'
but this statement throws an conversion error ( int to char error).
is there any way to fetch records from a select statement using a
string???
Thanks in Advance. 3 3202
shark wrote:
Hi All,
i hv created a sp as
Create proc P @iClientid varchar (100)
as
Begin
select * from clients where CONVERT(VACHAR( 100),iClientid) in(
@iclientid)
This does not work as you probably want. You get a selection criterium
with a single string @iClientid. You could have written
select * from clients where CONVERT(VACHAR( 100),iClientid) = @iclientid
end
where iclientid = int data type in the clients table.
now if i pass @iclientid as @iclientid = '49,12,112'
but this statement throws an conversion error ( int to char error).
is there any way to fetch records from a select statement using a
string???
If you need to pass in your id's the way you do, you can do it with
dynamic SQL, i.e. create a SQL statement and EXEC it.
robert
See Erland's article on the subject: http://www.sommarskog.se/arrays-in-sql.html
--
Hope this helps.
Dan Guzman
SQL Server MVP
"shark" <xa***********@ gmail.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
Hi All,
i hv created a sp as
Create proc P @iClientid varchar (100)
as
Begin
select * from clients where CONVERT(VACHAR( 100),iClientid) in(
@iclientid)
end
where iclientid = int data type in the clients table.
now if i pass @iclientid as @iclientid = '49,12,112'
but this statement throws an conversion error ( int to char error).
is there any way to fetch records from a select statement using a
string???
Thanks in Advance.
Where ','+@iClientid+ ',' like '%,+cast(iClien tid as varchar(20))+', %'
Madhivanan
Dan Guzman wrote:
See Erland's article on the subject: http://www.sommarskog.se/arrays-in-sql.html
--
Hope this helps.
Dan Guzman
SQL Server MVP
"shark" <xa***********@ gmail.comwrote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
Hi All,
i hv created a sp as
Create proc P @iClientid varchar (100)
as
Begin
select * from clients where CONVERT(VACHAR( 100),iClientid) in(
@iclientid)
end
where iclientid = int data type in the clients table.
now if i pass @iclientid as @iclientid = '49,12,112'
but this statement throws an conversion error ( int to char error).
is there any way to fetch records from a select statement using a
string???
Thanks in Advance.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Craig Keightley |
last post by:
is it possible to compare acomma separated list aginst another
eg comma list 1 => 1,2,3,4,5
comma list 2 => 3,5
can you check that 3 is in both, and 5 is in both, therfore they match???
the comparison is to check that if product a who supplies products 1,2,3,4,5
can be used instead of product b who supplies 3,5 as product a already
supplies them
|
by: Not Me |
last post by:
Hi,
I'm sure this is a common problem.. to create a single field from a
whole column, where each row would be separated by a comma.
I can do this for a specified table, and column.. and I've created a
function using VBA to achieve a more dynamic (and very slow) solution..
so I would like to implement it using a user defined function in sql server.
The problems I'm facing are, that I can't use dynamic sql in a
|
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: insomniux |
last post by:
Hi,
I'n in an environment where I cannot make stored procedures. Now I need
to make a query with a subquery in the SELECT part which gives a comma
separated list of results:
SELECT
p.id,
listFunction(SELECT name FROM names WHERE name_parent=p.id) AS
'nameList'
FROM projects AS p
|
by: AK |
last post by:
Once upon a time there was a table:
CREATE TABLE VENDOR(VENDOR_ID INT, NAME VARCHAR(50), STATE CHAR(2))@
in a while the developers realized that a vendor may be present in
xseveral states, so the structure was changed to
CREATE TABLE VENDOR(VENDOR_ID INT, NAME VARCHAR(50), STATE_LIST
VARCHAR(150))@
| |
by: phillip.s.powell |
last post by:
Ok, you have three tables. You're supposed to be able to not only sort
(ORDER BY) according to a_name, no problem, but you must also have the
ability to sort (ORDER BY) the relationship between table_a and
table_b, that is, say you have this:
Here is where the problem lies. I am required to be able to sort by
'Phil', no problem:
|
by: mac |
last post by:
Hi,
I'm trying to write a fibonacci recursive function that will return
the fibonacci string separated by comma. The problem sounds like this:
-------------
Write a recursive function that creates a character string containing
the first n Fibonacci numbers - F(n) = F(n - 1) + F(n - 2), F(0) =
F(1) = 1 -, separated by comma. n should be given as an argument to
the program. The recursive function should only take one parameter, n,
and...
|
by: mac |
last post by:
Hi,
I'm trying to write a fibonacci recursive function that will return
the fibonacci string separated by comma. The problem sounds like this:
-------------
Write a recursive function that creates a character string containing
the first n Fibonacci numbers - F(n) = F(n - 1) + F(n - 2), F(0) =
F(1) = 1 -, separated by comma. n should be given as an argument to
the program. The recursive function should only take one parameter, n,
and...
|
by: sufian |
last post by:
Below is the field where user enters his/her email address and the AJAX post request is sent to the server and the user sees the message:
echo("<div id=\"message\" class=\"success\">Thank you! You have been successfully registered.</div>");
within 1.5 seconds.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta...
|
by: flavourofbru |
last post by:
Hi,
In the datagridview control, one of my column has multiple values separated by a comma
Is there a way to get individaual values which are separated by a comma from that particular cells?
Thanks in advance,
Brugu
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |