Connecting Tech Pros Worldwide Help | Site Map

sql AS function not working

  #1  
Old 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
  #2  
Old July 3rd, 2009, 02:18 AM
ck9663's Avatar
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
  #3  
Old 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.
  #4  
Old 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.
  #5  
Old July 8th, 2009, 05:10 PM
ck9663's Avatar
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
  #6  
Old 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
Reply

Tags
sql


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why db.OpenRecordset("SQL STRING HERE", dbOpenDynaset) is not working ? MLH answers 22 July 13th, 2008 02:45 AM
Query from ORACLE board is not working in DB2 lenygold via DBMonster.com answers 11 June 27th, 2008 08:21 PM
Passing variable to SQL string is not working. glenn answers 5 April 21st, 2006 08:45 PM
SP and ADO Page Property Not Working Properly rhungund@gmail.com answers 1 December 3rd, 2005 11:35 AM