Try using a datatype of NVARCHAR instead of VARCHAR. I seem to remember running into this type of problem before...
HTH Shawn Grover -----Original Message----- From: Dina Hess [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 09, 2002 1:21 PM To: CF-Talk Subject: Re: Return a Sub-Query as a Comma Delimited List Hmmmm...the bottom was chopped off that last post....I'll try again: This is how I revised the query for pubs. Note that each au_id is 11 characters in length and I increased the list size to 8000 characters. DECLARE @AuthorList varchar(8000) SELECT @AuthorList = COALESCE(@AuthorList + ',', '') + CAST(au_id AS varchar(11)) FROM au_id SELECT @AuthorList This is the query I used to verify the number of author ids that should have been returned. select count(au_id) from authors When I ran that query through SQL (version 7) Query Analyzer, I *did* get a comma delimited list...sort of. It truncated the list to include only 22 ids. But when I ran a query to count the number of ids in the table, I came up with 23. 23 ids at 11 characters each totals 253 characters. The last id was truncated to 3 characters because the column length appears to truncate to 256 characters, regardless of the size of the varchar specified in the declaration. My point is that there appears to be a caveat: the size of the list must be 256 characters or less. But, maybe I'm missing something here... All that aside, my thanks to both you and Mark for pointing out that it is indeed possible to project a small list of values from the select statement. *** AFAIK, cast and convert are both used to convert one data type to another but Cast is the SQL 92 standard. Convert offers the added feature of being able to specify the format when converting a datetime value to a character string. So when you do this: select convert(char(8),getdate(),112) the third argument, 112, specifies the format: 20021009. ----- Original Message ----- From: "S. Isaac Dealey" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Wednesday, October 09, 2002 12:13 PM Subject: Re: Return a Sub-Query as a Comma Delimited List > >> DECLARE @EmployeeList varchar(100) > >> > >> SELECT @EmployeeList = COALESCE(@EmployeeList + ',', '') + > >> CAST(Emp_UniqueID AS varchar(5)) > >> FROM SalesCallsEmployees > >> WHERE SalCal_UniqueID = 1 > >> > >> SELECT @EmployeeList > > > I ran that code snippet through the SQL Query Analyzer after > > customizing it for the pubs database and got this: > > And got what? > > It produced a comma delimited list for me on MSSQL2K ... > I didn't try it on MSSQL7. > > I also used CONVERT(varchar,myid) instead of CAST > > Speaking of which -- does anyone here know the difference between convert > and cast? Do they exist to solve different problems? Is one of them SQL92 > standard and the other one MS proprietary? Has one of them been deprecated? > Or did someone at MS just figure they'd kill one bird with 2 stones? > > > > S. Isaac Dealey > Certified Advanced ColdFusion 5 Developer > > www.turnkey.to > 954-776-0046 > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com

