I hate to be redundant in asking for help on a problem already solved and I am attempting to use either of the recommended solutions listed in FAQ183-2146 (Concatenating a one-to-many relationship into a single column) with a twist.
Let me say this faq was tremendously helpful, enlightening has me close to my finish line; however, I am still having problems with my situation because I am wanting to concatenate varchar fields versus int fields. I've tried both solutions and run into errors each time.
********************************
----------Solution 1: (bperry)-----------
MY CODE CHANGES:
CREATE TABLE #TempTable (
txtISBN varchar(10),
txtAuthors varchar(20) ,
)
-- Create a forward-only cursor to collect the data
declare myCursor INSENSITIVE CURSOR FOR
Select dblISBN, txtAuthor
From tmpROSI
Open myCursor
-- Create the local variables needed
declare @currKey varchar(10),
declare @prevKey varchar(10),
declare @currLine varchar(20)
declare @BigLine varchar(200)
.
.
.
*********MY ERROR R E S U L T S ***********
(1 row(s) affected)
.
.
.
Server: Msg 245, Level 16, State 1, Line 34
Syntax error converting the varchar value '186450207X' to a column of data type int.
********************************
----------Solution 2
tbroadbent)-----------
---------------------
MY CODE CHANGES:
Create table #tmp(
dblISBN varchar(10),(,
Authors varchar(8000)(
)
Insert #tmp
Select Distinct dblISBN,''
From tmpROSI
Declare @ln int, @mln int
Select @ln=1, @mln= Count (txtAuthor)
From tmpROSI
.
.
.
*********MY ERROR R E S U L T S ***********
(49 row(s) affected)
.
.
.
Server: Msg 245, Level 16, State 1, Line 18
Syntax error converting the varchar value 'Hull, Rikki' to a column of data type int.
Thanks in advance for your help. You all are really the best solution source.
Kathy
When you dig another out of their troubles, you find a place to bury your own.—Anonymous
The person who says it can't be done shouldn't interrupt the person who is doing it.—Chinese Proverb
Let me say this faq was tremendously helpful, enlightening has me close to my finish line; however, I am still having problems with my situation because I am wanting to concatenate varchar fields versus int fields. I've tried both solutions and run into errors each time.
********************************
----------Solution 1: (bperry)-----------
MY CODE CHANGES:
CREATE TABLE #TempTable (
txtISBN varchar(10),
txtAuthors varchar(20) ,
)
-- Create a forward-only cursor to collect the data
declare myCursor INSENSITIVE CURSOR FOR
Select dblISBN, txtAuthor
From tmpROSI
Open myCursor
-- Create the local variables needed
declare @currKey varchar(10),
declare @prevKey varchar(10),
declare @currLine varchar(20)
declare @BigLine varchar(200)
.
.
.
*********MY ERROR R E S U L T S ***********
(1 row(s) affected)
.
.
.
Server: Msg 245, Level 16, State 1, Line 34
Syntax error converting the varchar value '186450207X' to a column of data type int.
********************************
----------Solution 2
---------------------
MY CODE CHANGES:
Create table #tmp(
dblISBN varchar(10),(,
Authors varchar(8000)(
)
Insert #tmp
Select Distinct dblISBN,''
From tmpROSI
Declare @ln int, @mln int
Select @ln=1, @mln= Count (txtAuthor)
From tmpROSI
.
.
.
*********MY ERROR R E S U L T S ***********
(49 row(s) affected)
.
.
.
Server: Msg 245, Level 16, State 1, Line 18
Syntax error converting the varchar value 'Hull, Rikki' to a column of data type int.
Thanks in advance for your help. You all are really the best solution source.
Kathy
When you dig another out of their troubles, you find a place to bury your own.—Anonymous
The person who says it can't be done shouldn't interrupt the person who is doing it.—Chinese Proverb