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 |
djs42
Starting Member
4 Posts |
Posted - 2013-06-13 : 11:27:07
|
I have several views in which I rename the data fields:SELECT Name, Item10 AS Value, Item11 AS Type, Item29 AS LastFieldFROM dbo.databaseWHERE (LEFT(Name,3)='11-')ORDER BY NameI want to use CAST to define the data type returned by the views:CAST (Value as VARCHAR)What is the correct syntax for both renaming and CASTing the data type? |
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2013-06-13 : 11:42:25
|
is this something you're looking for? SELECT Name,CAST(Item10 as Varchar(specify the length in which item10 value can get fit in)) AS Value,.........Order By NameCheersMIK |
|
|
djs42
Starting Member
4 Posts |
Posted - 2013-06-13 : 12:23:18
|
MIK,Thanks - works exactly as I want!Stringing together SQL in the correct syntax always seems to be my biggest hurdle. |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2013-06-13 : 12:35:51
|
you're welcome~!CheersMIK |
|
|
|
|
|