Click here to Skip to main content
15,896,457 members
Home / Discussions / Database
   

Database

 
AnswerRe: read & update using reader Pin
Jason Christian14-Dec-10 8:44
Jason Christian14-Dec-10 8:44 
Questionconverting column values to column. [modified] Pin
livewire1310-Dec-10 18:39
livewire1310-Dec-10 18:39 
AnswerRe: converting column values to column. Pin
Kasson10-Dec-10 20:29
Kasson10-Dec-10 20:29 
AnswerRe: converting column values to column. Pin
thatraja10-Dec-10 20:32
professionalthatraja10-Dec-10 20:32 
AnswerRe: converting column values to column. Pin
Goutam Patra10-Dec-10 21:08
professionalGoutam Patra10-Dec-10 21:08 
AnswerRe: converting column values to column. Pin
Mycroft Holmes11-Dec-10 20:28
professionalMycroft Holmes11-Dec-10 20:28 
AnswerRe: converting column values to column. Pin
RaviRanjanKr20-Dec-10 18:22
professionalRaviRanjanKr20-Dec-10 18:22 
QuestionHow to convert varchar values to int while passing as an in parameter? Pin
meeram39510-Dec-10 0:25
meeram39510-Dec-10 0:25 
I have an sql query which gives the output as follows:

OutputFileid
-----------
4
5
6

I want to get this output in horizontal fashion , like 4,5,6 so that I can pass to another query as an 'in' parameter.

I was getting that, but the second query returned an error saying that "Conversion failed when converting the varchar value '4,5,6' to data type int".

Following is the full stored procedure which i am using for getting the desired result.

ALTER procedure [dbo].[IsBCastRefExistsforProcess]
(@processId int)
as
begin
DECLARE @FILEIDs varchar(100)
select @FILEIDs= COALESCE(@FILEIDs+',' ,'')+ convert(varchar,outputfileid)+''from OutputFiles where ProcessId = @processid
PRINT @FILEIDs
if (LEN(@FILEIDs) > 0)
begin
	
select eg.EJVColumnId,eg.EJVColumnName
from EJVGedaColumns eg,
GedaColumnMapping gc
where eg.EJVColumnId = gc.EJVColumnId
and eg.EJVColumnName like '%BCAST_REF%'
and gc.OutputFileid in (@FILEIDs)
end
end


when I tried to execute exec IsBCastRefExistsforProcess 1234 it is giving the above error. Is there anyway which i can achieve this?
select @FILEIDs= COALESCE(@FILEIDs+',' ,'')+ convert(varchar,outputfileid)+''from OutputFiles where ProcessId = @processid

This gives me the values in horizontal fashion.

I tried giving 'and gc.OutputFileid in (Convert(int,@FILEIDs)) - But end up with same error.
Please help.

Thanks
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.

AnswerRe: How to convert varchar values to int while passing as an in parameter? Pin
meeram39510-Dec-10 0:40
meeram39510-Dec-10 0:40 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
Hiren solanki10-Dec-10 1:33
Hiren solanki10-Dec-10 1:33 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
meeram39512-Dec-10 19:14
meeram39512-Dec-10 19:14 
AnswerRe: How to convert varchar values to int while passing as an in parameter? Pin
Eddy Vluggen10-Dec-10 0:59
professionalEddy Vluggen10-Dec-10 0:59 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
PIEBALDconsult10-Dec-10 2:43
mvePIEBALDconsult10-Dec-10 2:43 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
Eddy Vluggen10-Dec-10 4:55
professionalEddy Vluggen10-Dec-10 4:55 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
meeram39512-Dec-10 19:14
meeram39512-Dec-10 19:14 
GeneralRe: How to convert varchar values to int while passing as an in parameter? Pin
Jörgen Andersson10-Dec-10 4:10
professionalJörgen Andersson10-Dec-10 4:10 
QuestionJoin in MYSQL Pin
bhavnvyas9-Dec-10 22:11
bhavnvyas9-Dec-10 22:11 
AnswerRe: Join in MYSQL Pin
Luc Pattyn9-Dec-10 22:51
sitebuilderLuc Pattyn9-Dec-10 22:51 
GeneralRe: Join in MYSQL Pin
Jörgen Andersson10-Dec-10 0:57
professionalJörgen Andersson10-Dec-10 0:57 
GeneralRe: Join in MYSQL Pin
Luc Pattyn10-Dec-10 1:07
sitebuilderLuc Pattyn10-Dec-10 1:07 
GeneralRe: Join in MYSQL Pin
Kasson10-Dec-10 20:30
Kasson10-Dec-10 20:30 
Questionlarge SQL table update performance Pin
KLPounds9-Dec-10 6:01
KLPounds9-Dec-10 6:01 
AnswerRe: large SQL table update performance Pin
David Mujica9-Dec-10 6:44
David Mujica9-Dec-10 6:44 
GeneralRe: large SQL table update performance Pin
KLPounds9-Dec-10 7:32
KLPounds9-Dec-10 7:32 
GeneralRe: large SQL table update performance Pin
David Mujica9-Dec-10 9:25
David Mujica9-Dec-10 9:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.