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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Defining data types

Author  Topic 

Timmy6
Starting Member

8 Posts

Posted - 2009-01-22 : 09:22:07
I have a Select statement that performs a calculation and places it in a new column called Amount_Loc_Curr as below

SELECT tbl1.GL_Ac, RIGHT(tbl1.Profit_Center,5) AS Profit_Center, tbl1.Cost_Center, tbl1.Amount_Loc_Curr * tbl2.Restate AS Amount_Loc_Curr

However 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
Go to Top of Page

Timmy6
Starting Member

8 Posts

Posted - 2009-01-22 : 09:47:39
Great thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-22 : 12:04:32
welcome
Go to Top of Page
   

- Advertisement -