dbTalk Databases Forums  

Auto-generated fields

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Auto-generated fields in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
saomot2000
 
Posts: n/a

Default Auto-generated fields - 09-02-2004 , 06:03 AM






How can I use an automatically generated field(column) that is derived from
other columns of the same table as a variable in generating another column
within the same query on SQL Server.
I tried this on MS Access and it worked quite well.
An example of such query is given below:

SELECT debits, credits, balance, (balance-credits-debits) AS
previousbalance, (previousbalance-balance) AS movement
FROM sampletable;

Thanks for anticipated response.

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Auto-generated fields - 09-02-2004 , 02:24 PM






Does this query not work in SQL Server or did I miss the point because it
looks good to me. Where does the variable bit fit in? DTS is interested in
MetaData so

SELECT ..........................(Horse + Dog) as Collection.............
SELECT ..........................(a + b) as Collection.............
SELECT ..........................(1 + 2) as Collection.............
SELECT ..........................(Me + You) as Collection.............

will all work providing the output is compatible.

If you need to dynamically suggest what is in the parentheses then you can
use this

Global Variables and SQL statements in DTS
(http://www.sqldts.com/Default.aspx?205)

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"saomot2000" <saomot2000 (AT) discussions (DOT) microsoft.com> wrote

Quote:
How can I use an automatically generated field(column) that is derived
from
other columns of the same table as a variable in generating another column
within the same query on SQL Server.
I tried this on MS Access and it worked quite well.
An example of such query is given below:

SELECT debits, credits, balance, (balance-credits-debits) AS
previousbalance, (previousbalance-balance) AS movement
FROM sampletable;

Thanks for anticipated response.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.