Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I have this function from VB Script and I thought it would be easy to convert, but I must have a mental block. Maybe someone could point me the right way:
Function ScrubMyID (Type,Aid,AltID,I_Number) SELECT CASE Type CASE "00" ScrubMyID = AltID CASE "01" ScrubMyID = Aid CASE "02" ScrubMyID = AltID CASE "03" ScrubMyID = AltID END SELECT IF MID(ScrubMyID,1,1) = "." THEN ScrubMyID = I_NumberEnd Function
Duane
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2012-01-13 : 03:56:27
its almost the same
CREATE FUNCTION ScrubMyID (@Type varchar(5),@Aid int,@AltID int,@I_Number int)RETURNS intASBEGINDECLARE @RID intSELECT @RID = CASE WHEN @Type IN ('00','02','03') THEN AltID WHEN @Type ='01' THEN Aid ENDSELECT @RID = CASE WHEN LEFT(@RID,1) = '.' THEN @I_Number ELSE @RID ENDRETURN @RIDEND
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
duanecwilson
Constraint Violating Yak Guru
273 Posts
Posted - 2012-01-13 : 15:05:26
Thank you. This is good, better than the work-around I finally figured out late yesterday.Duane
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2012-01-14 : 00:02:21
wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/