General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
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?
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only