May 15, 2008 at 8:28 pm
How does SQL 2005 decide what datatype to give a column?
I want SQL to use unicode data types, but it uses varchar instead of nvarchar for the view.
Can I force it to use nvarchar?
May 16, 2008 at 1:02 am
Hi ;
I suggest this :
CREATE VIEW [Students_vw] (NAME , Surname)
AS
SELECT CAST([Name] AS NVARCHAR(50)) , CAST([Soyad], AS NVARCHAR(50))
FROM Students
May 16, 2008 at 1:26 am
The data type of columns in a view will be the data type of the columns in the underlying table, unless there's a CAST/Convert used.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 16, 2008 at 6:20 am
If the data type of the underlying table is VARCHAR, why would you want to double the size of the returned data in the view and wreck any of your indexes? You do not have a possibility of having anything not supported by the underlying data type.
May 16, 2008 at 8:42 am
Yes, you can force a view to use a different data type than the underlying table. The question is, why would you? It won't gain you anything at all in this case.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply