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
 General SQL Server Forums
 New to SQL Server Programming
 convert text to varchar

Author  Topic 

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2007-10-22 : 05:03:56
hi,

i would like to convert text string(field) to varchar so I can use later group by a special string.

what shall i use?

thank you

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-10-22 : 05:23:30
look up convert function

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-10-22 : 05:32:40
Make sure text string does not exceed the limit of varchar i.e. 8000 characters.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2007-10-22 : 05:56:13
I use this:

select
convert(varchar(10), note) as new_note,
count(new_note) as frequency
from table1
group by new_note

but i will not perform group by.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-22 : 06:34:51
quote:
Originally posted by slimt_slimt

I use this:

select
convert(varchar(10), note) as new_note,
count(new_note) as frequency
from table1
group by new_note

but i will not perform group by.


Your statement seems unclear. Did you mean this?

select
convert(varchar(10), note) as new_note,
count(convert(varchar(10), note) ) as frequency
from table1
group by convert(varchar(10), note)



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

shivashankardep
Starting Member

2 Posts

Posted - 2007-10-22 : 06:42:33
hi use
convert(varchar(10),'text')
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-22 : 06:54:17
quote:
Originally posted by shivashankardep

hi use
convert(varchar(10),'text')


Did you read the question fully?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2007-10-22 : 08:28:09
Madhivanan; your code is not working properly..... Did I miss anything?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-10-22 : 08:33:57
quote:
Originally posted by slimt_slimt

Madhivanan; your code is not working properly..... Did I miss anything?



Post your query here


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -