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.
| Author |
Topic |
|
bharatagraj
Starting Member
6 Posts |
Posted - 2005-08-19 : 14:03:00
|
| Hi All there -I want to show the o/p of a cursor on a single line. There is a numeric variable that needs to be clubed with the character variable. If I use char() the o/p is not right. How do I do that? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-08-19 : 15:18:56
|
| Please post your code as well as show us the output that you expect as I don't understand what you are asking for.Tara |
 |
|
|
bharatagraj
Starting Member
6 Posts |
Posted - 2005-08-19 : 15:55:07
|
| MY CODE IS -declare @name char(30)declare @homebase char(40)declare @style char(20)declare @artist_id intdeclare Artist_cursor cursorfor select * from artistsopen Artist_cursorfetch Artist_cursor into @name, @homebase, @style, @artist_id while (@@fetch_status = 0)Begin Print @name + @homebase + @style + char(@artist_id) fetch Artist_cursor into @name, @homebase, @style, @artist_idend close Artist_cursordeallocate Artist_cursorTHE O/P isServer: Msg 16915, Level 16, State 1, Line 6Crowded House New Zealand Pop Dave Matthews Band Charlottesville Rock Edward MacDowell U.S.A. Classical Mary Chapin-Carpenter Nashville Country Maurice Ravel France Classical Oingo Boingo Los Angeles Pop Soul Ascylum Minneapolis Rock Vince Gill Nashville Country ------Here when I converted to char() you can see the o/p as |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-08-19 : 16:07:22
|
| Lookup CHAR() in Books On-Line. It does now do what you think it does. You need to use CONVERT to convert a numeric value into a string representation.On top of that, why are you using a cursor? |
 |
|
|
|
|
|