sql AS function not working 
July 2nd, 2009, 03:42 PM
| | Newbie | | Join Date: Jul 2009 Location: Loganville GA
Posts: 3
| | |
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
| 
July 3rd, 2009, 02:18 AM
|  | Expert | | Join Date: Jun 2007
Posts: 1,907
Provided Answers: 1 | | | re: sql AS function not working
Try passing 3 parameters instead of just 1
--- CK
| 
July 3rd, 2009, 12:06 PM
| | Newbie | | Join Date: Jul 2009 Location: Loganville GA
Posts: 3
| | | 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.
| 
July 8th, 2009, 10:42 AM
| | Newbie | | Join Date: Jul 2009
Posts: 5
| | | 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.
| 
July 8th, 2009, 05:10 PM
|  | Expert | | Join Date: Jun 2007
Posts: 1,907
Provided Answers: 1 | | | 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
| 
July 8th, 2009, 06:42 PM
| | Newbie | | Join Date: Jul 2009 Location: Loganville GA
Posts: 3
| | | re: sql AS function not working
Got it figured out, sometimes I feel so stupid, duh...
Thanks
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,535 network members.
|