Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why this does not work
Message
 
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
00726046
Message ID:
00726064
Views:
29
REPLACE(a.group_, '-', '') will remove dashes from a string. Keep in mind that it'll work in SQL Server 7.0 and later.

>patindex() returns you the first occurance of "-" in a string. So if it is greater than 0 means there is "-" in the string. Why I am doing this beacuse sometimes value in INS_GROUP1 in header table does not have "-" but in Accounts table(a) this is present. These two are same as "-" must be removed in the query only and not in actual field.
>
>Now substring() + substring() should return me whole field value except the "-" sign and then I compare with h.ins_paynum which is already without "-"
>if
>patindex("%-%", a.GROUP_ ) > 0
>
>then
>
>h.INS_GROUP1 = substring(a.GROUP_ ,1, (patindex("%-%", a.GROUP_ ) - 1)) + substring(a.Group_,(patindex("%-%", a.GROUP_ )+ 1), datalength(a.Group_)) and
>.
>
> I think replace will do the same?
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform