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 2008 Forums
 Transact-SQL (2008)
 Crystal Formula to SQL

Author  Topic 

Jysafe
Starting Member

6 Posts

Posted - 2013-11-16 : 09:52:23
Hi,

I have been trying to convert the Crystal formula below into T-SQL, but I'm not able to do that. Anyone has any idea on how to convert this?

replace(space(3-len({Cono})), ' ', '1') + {Cono} +
(if len(cstr({empno}, 0, '')) < 4 then
replace(space(4-len(cstr({empno}, 0, ''))), ' ', '0')
) +
cstr({empno}, 0, '')


Thanks!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-11-16 : 13:26:17
[code]SELECT RIGHT('111' + CAST(Cono AS VARCHAR(3)), 3) + RIGHT('0000' + CAST(EmpNo AS VARCHAR(4)), 4)[/code]


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
   

- Advertisement -