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 |
|
matthisco
Starting Member
48 Posts |
Posted - 2010-04-30 : 06:53:37
|
| Hi, When I try and output an ntext field, it appears with no column name, can anyone tell me how I can give it a name so I can reference it?Its the documentdescription field:SELECT documentcategoryname, documentname, documentid,documentcat, documentcategoryid, CAST(documentdescription as varchar(8000)) FROM documents INNER JOIN documentcategory ON documents.documentcat = documentcategory.documentcategoryid where documentsiteid = @siteid group by documentcategoryname, documentname, documentid,documentcat, documentcategoryid, CAST(documentdescription as varchar(8000)) |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-30 : 07:30:39
|
You give each column in the select list an alias name:SELECT documentcategoryname, documentname, documentid,documentcat, documentcategoryid, CAST(documentdescription as varchar(8000)) as documentdescriptionFROM documents INNER JOIN documentcategory ON documents.documentcat = documentcategory.documentcategoryid where documentsiteid = @siteid group by documentcategoryname, documentname, documentid,documentcat, documentcategoryid, CAST(documentdescription as varchar(8000)) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-04-30 : 09:00:15
|
| Also note that converting ntext to varchar(8000) may cause data loss you may need to use varchar(max)MadhivananFailing to plan is Planning to fail |
 |
|
|
matthisco
Starting Member
48 Posts |
Posted - 2010-04-30 : 09:53:00
|
| Thanks very much guys for your advice, really appreciate it |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-01 : 04:46:04
|
quote: Originally posted by madhivanan Also note that converting ntext to varchar(8000) may cause data loss you may need to use varchar(max)MadhivananFailing to plan is Planning to fail
or nvarchar(max) if you have unicode data------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-07 : 03:28:24
|
quote: Originally posted by visakh16
quote: Originally posted by madhivanan Also note that converting ntext to varchar(8000) may cause data loss you may need to use varchar(max)MadhivananFailing to plan is Planning to fail
or nvarchar(max) if you have unicode data------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Yes. You are correct MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|