Is it possible to change the datatype of a column in a view?

database, sql-server-2008, sqldatatypes, t-sql, view

Solution

Sure

CREATE VIEW AView
AS
SELECT CAST(title AS char(50))
FROM titles

So check out CAST and also CONVERT on the msdn pages for full info

Problem

Usually I run a script like this: ``` ALTER TABLE [TABLE] ALTER COLUMN [Column] NVARCHAR(40); ``` The result is that the field in the table gets converted to nvarchar. But what is the syntax for doing the same thing for a view? Or is that even possible?

Original source