i'm removing zero cost sql duty concatting fields


i have following function:



create duty fgettransactionstatuslog
(
@transactionid int
)
returns varchar(8000)
begin

declare statuschanges cursor for
name newstatusid, firstname + ' ' + lastname username, stamp, cast(notes varchar(8000)) notes
transactionstatuschanges tsc
left join users us tsc.userid = us.userid
where transactionid = @transactionid method statusnum

declare @output varchar(8000)

declare @newstatusid char(2)
declare @username varchar(255)
declare @stamp datetime
declare @notes varchar(8000)

set @output = ''

open statuschanges
fetch unbroken statuschanges @newstatusid, @username, @stamp, @notes
while @@fetch_status = 0
begin

set @output = @output + rtrim(cast(@stamp varchar(30))) + ': ' + @newstatusid + ' ' + @username + char(13) + char(10)

@notes null
begin
set @output = @output + '---' + @notes + char(13) + char(10)
end

fetch unbroken statuschanges @newstatusid, @username, @stamp, @notes
end
close statuschanges
deallocate statuschanges

return @output

end


now, duty advantage accurately i wish sell don't have any annals any records...
for transaction have during slightest record transactionstatuschanges non-null annals field, i null.



i don't definitely it, given i am checking @notes zero before concatting it.



any ideas?



note: i'm controlling varchar(8000) since i can't calm inside functions.



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?