Link to home
Start Free TrialLog in
Avatar of javierfh
javierfh

asked on

Sql Server 2005

How to convert the integer field to string  a view sql?
Avatar of nilsarne82
nilsarne82

SELECT CAST ( [yourField] AS NVARCHAR(50) ) 
SELECT CONVERT( NVARCHAR(50), yourField ) 

Open in new window


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


See MSDN
ASKER CERTIFIED SOLUTION
Avatar of Gugro
Gugro

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lcohan
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.