Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I have a Select statement that performs a calculation and places it in a new column called Amount_Loc_Curr as belowSELECT tbl1.GL_Ac, RIGHT(tbl1.Profit_Center,5) AS Profit_Center, tbl1.Cost_Center, tbl1.Amount_Loc_Curr * tbl2.Restate AS Amount_Loc_CurrHowever I want to define the data type of the new column as it seems to be defaulting it to nvarchar(255), do I need to make this definition upfront or on the same line above?
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-01-22 : 09:23:39
then use cast or convert like
SELECT tbl1.GL_Ac, RIGHT(tbl1.Profit_Center,5) AS Profit_Center, tbl1.Cost_Center, CAST(tbl1.Amount_Loc_Curr * tbl2.Restate AS yourdatatype) AS Amount_Loc_Curr