Thursday, March 22, 2012

Creating a table from a view with an if condition.

I'm trying to create a table using a view that links 3 tables (d inner join(
s
join ds)). Is it possible to do an IF condition on line #2 that if the
expression returns a negative value to replace it with a 0 else return the
expression value. I was wondering if there's a way to do the if condition
before the create table other than first creating the table and then do an
update query on the QOH column
select D.*, S.SHORT_SUM_QTY,
(DS.REQD_SUM_QTY - S.SHORT_SUM_QTY) AS QOH
INTO MA_MRP_DS
FROM Select . . .Look at the CASE expression in the books online. It will do this.
----
Louis Davidson - drsql@.hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Blog - http://spaces.msn.com/members/drsql/
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)
"danlin" <danlin@.discussions.microsoft.com> wrote in message
news:A64B882A-9232-4DC8-8D0C-74D9EEC64B3B@.microsoft.com...
> I'm trying to create a table using a view that links 3 tables (d inner
> join(s
> join ds)). Is it possible to do an IF condition on line #2 that if the
> expression returns a negative value to replace it with a 0 else return the
> expression value. I was wondering if there's a way to do the if condition
> before the create table other than first creating the table and then do an
> update query on the QOH column
> select D.*, S.SHORT_SUM_QTY,
> (DS.REQD_SUM_QTY - S.SHORT_SUM_QTY) AS QOH
> INTO MA_MRP_DS
> FROM Select . . .
>

No comments:

Post a Comment