dbTalk Databases Forums  

Bad Stored Procedure Code: Why?

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Bad Stored Procedure Code: Why? in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gene Wirchenko
 
Posts: n/a

Default Bad Stored Procedure Code: Why? - 04-04-2011 , 04:26 PM






Dear SQLers:

I have written the following stored procedure:

create procedure NiceString
@strIn nvarchar(max),
@strOut nvarchar(max) output
with recompile
as
begin
select @strOut=
ltrim(rtrim(replace(replace(@strIn,nchar(9),N' '),N' ',N' ')))
/* */ select N'NiceString Result:',@strOut
end
go

It works to the degree that the result select shows the correct
value when I run it, but the value of strOut does not get back to the
caller in the following sequence, and strAfter still has its initial
value:

use Banking
go

declare @strBefore nvarchar(max)=N' This is an example. '
declare @strAfter nvarchar(max)=N'*** not assigned to ***'

select @strBefore
execute NiceString @strBefore,@strAfter
select @strAfter

use master
go

What am I missing, please?

Sincerely,

Gene Wirchenko

Reply With Quote
  #2  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Bad Stored Procedure Code: Why? - 04-04-2011 , 04:44 PM






On Mon, 04 Apr 2011 14:26:33 -0700, Gene Wirchenko <genew (AT) ocis (DOT) net>
wrote:

[snip]

Quote:
execute NiceString @strBefore,@strAfter
[snip]

Quote:
What am I missing, please?
I found it myself.

The call should be
execute NiceString @strBefore,@strAfter output

This is the sort of thing that should get a warning or error
message.

Sincerely,

Gene Wirchenko

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.