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
 Transact-SQL (2000)
 What's wrong with this syntax?

Author  Topic 

Job
Yak Posting Veteran

69 Posts

Posted - 2005-08-12 : 08:35:43
Set Fxd_Units =
CASE
WHEN TxnUnitsBase = Null
THEN Fxd_Units = left(TxnUnitsDur,len(TxnUnitsDur)-1)/15

WHEN (TxnUnitsBase <> Null and TxnUnits like '%,%' and TxnUnits not like '%M%')
THEN Fxd_Units = TxnUnitsBase

WHEN TxnUnitsBase <> Null
THEN Fxd_Units = left(TxnUnitsDur,len(TxnUnitsDur)-1)/15 + TxnUnitsBase
END
Where TxnUnits like '%M%' or TxnUnits like '%,%'

Any help is appreciated.

Cheers,

Job

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-12 : 08:45:19
you are missing the FROM part.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Job
Yak Posting Veteran

69 Posts

Posted - 2005-08-12 : 09:05:23
sorry i forgot to put the update in there

Update Tbl_Txn_UT
Set Fxd_Units =
CASE
WHEN TxnUnitsBase = Null
THEN Fxd_Units = left(TxnUnitsDur,len(TxnUnitsDur)-1)/15
WHEN (TxnUnitsBase <> Null and TxnUnits like '%,%' and TxnUnits not like '%M%')
THEN Fxd_Units = TxnUnitsBase
WHEN TxnUnitsBase <> Null
THEN Fxd_Units = left(TxnUnitsDur,len(TxnUnitsDur)-1)/15 + TxnUnitsBase
END
Where TxnUnits like '%M%' or TxnUnits like '%,%'
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-12 : 09:09:51
Replace = Null by Is Null and <> Null by is not null

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Job
Yak Posting Veteran

69 Posts

Posted - 2005-08-12 : 09:38:20
Ok, I just didn't have to restate the field names that are explicit in the set statment. So this works;

Update Tbl_Txn_UT
Set Fxd_Units =
CASE
WHEN TxnUnitsBase = Null
THEN left(TxnUnitsDur,len(TxnUnitsDur)-1)/15
WHEN (TxnUnitsBase <> Null and TxnUnits like '%,%' and TxnUnits not like '%M%')
THEN TxnUnitsBase
WHEN TxnUnitsBase <> Null
THEN left(TxnUnitsDur,len(TxnUnitsDur)-1)/15 + TxnUnitsBase
END
Where TxnUnits like '%M%' or TxnUnits like '%,%'
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-12 : 09:42:11
Are you sure that works?
See my prevoius reply

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Job
Yak Posting Veteran

69 Posts

Posted - 2005-08-12 : 11:18:19
No Madhivanan,

You are right, it didn't work on all of the records

I had to change it..

quote:
Originally posted by madhivanan

Are you sure that works?
See my prevoius reply

Madhivanan

Failing to plan is Planning to fail

Go to Top of Page
   

- Advertisement -