Sql Server 2005

javierfh
javierfh used Ask the Experts™
on
How to convert the integer field to string  a view sql?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
SELECT CAST ( [yourField] AS NVARCHAR(50) ) 
SELECT CONVERT( NVARCHAR(50), yourField ) 

Open in new window


CREATE VIEW <yourView> AS
 SELECT CAST(... )


See MSDN
Commented:
SELECT STR(1234)
lcohanDatabase Analyst

Commented:
CREATE VIEW my_view
AS
select cast(id as sysname),     -- this is the int field and you could use varchar or nvarchar instead of sysname
           name
FROM my_table
GO

http://msdn.microsoft.com/en-us/library/ms187928.aspx

Check implicit conversion chart at the end of above article.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial