Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Formatting Output

Author  Topic 

ramoneguru
Yak Posting Veteran

69 Posts

Posted - 2006-07-06 : 14:38:28
Ok, I'm somewhat lazy and I have this problem:

I have a bunch of codes that I need to lookup using this query:

SELECT OptionCode, TestName, NewCode FROM Assessment
WHERE TestName = 'Math'

Output looks like this:
123 Math 1
234 Math 1
456 Math 1
789 Math 1
.
.
.

Now I have to update the 'NewCode' to the number 116 (it currently is 1) but I'm using this update statment:

UPDATE Assessment
SET NewCode = 116
WHERE TestName = 'Math'
AND OptionCode IN (
123,
234,
456,
789,
.
.
.
)

I cut/paste the OptionCode from the grid, but manually typed in the comma (numbers are non sequential). Is there a way I can insert a comma so all I need to do is just cut/paste and not manually type anything?
--Nick

X002548
Not Just a Number

15586 Posts

Posted - 2006-07-06 : 14:45:17
Nothing wrong with lazy. Assuming OptionCode is Numeric

SELECT DISTINCT ', ' + CONVERT(varchar(15),OptionCode) FROM Assessment
WHERE TestName = 'Math'
ORDER BY OptionCode

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

ramoneguru
Yak Posting Veteran

69 Posts

Posted - 2006-07-06 : 15:13:56
Sweeeeeeeet, thanks.
--Nick
Go to Top of Page
   

- Advertisement -