Connecting Tech Pros Worldwide Help | Site Map

sql AS function not working

Newbie
 
Join Date: Jul 2009
Location: Loganville GA
Posts: 3
#1: Jul 2 '09
I've been working on the following sp for a few days now. This is a stripped down version. It functions correctly, however when I run it (in the sql server mgt console), it returns the column as "(No column name)". Using "select @WrkStr AS StrOut" does not set the column name as StrOut. Any suggestions would be greatly appreciated.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[sp_Test]
@IncRecIdx int,
@TmpStr varchar(50),
@WrkStr varchar(8000)
AS
---------------------------------------------------------------------------------
set @TmpStr = (select case when chkInc_Abuse_Alleged = 1 then
'Abuse Alleged' else null end from Incident_4 where IncRecIdx = @IncRecIdx)
if len(@WrkStr) = 0 or @WrkStr is null
set @WrkStr = @TmpStr
else
set @WrkStr = @WrkStr + ', ' + @TmpStr
---------------------------------------------------------------------------------
set @TmpStr = (select case when chkInc_Burn = 1 then
'Burn' else null end from Incident_4 where IncRecIdx = @IncRecIdx)
if len(@WrkStr) = 0 or @WrkStr is null
set @WrkStr = @TmpStr
else
set @WrkStr = @WrkStr + ', ' + @TmpStr
---------------------------------------------------------------------------------

select @WrkStr AS StrOut

--exec sp_Incident_4_Test 1001
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Jul 3 '09

re: sql AS function not working


Try passing 3 parameters instead of just 1


--- CK
Newbie
 
Join Date: Jul 2009
Location: Loganville GA
Posts: 3
#3: Jul 3 '09

re: sql AS function not working


It only accepts 1 parameter, If I try exec sp_Incident_4_Test 1001, ' ', ' ' i receive the error message Procedure or function sp_Incident_4_Test has too many arguments specified.
Newbie
 
Join Date: Jul 2009
Posts: 5
#4: Jul 8 '09

re: sql AS function not working


How r u executing this SP?

Pls provide exec Statement...

As the statement written over here is not matching with your SP name in which u r facing problem.
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#5: Jul 8 '09

re: sql AS function not working


And the SP parameter on the script is 3, yet there's an error that it can not accept 3 parameters.

-- CK
Newbie
 
Join Date: Jul 2009
Location: Loganville GA
Posts: 3
#6: Jul 8 '09

re: sql AS function not working


Got it figured out, sometimes I feel so stupid, duh...

Thanks
Reply

Tags
sql