Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STORED PROCEDURE ERRORS!!!!!!!

Status
Not open for further replies.

pwel

Programmer
Aug 18, 1999
79
GB
Hi,

I get the following Error with this Procedure Call (SQL Server 7, SP2):

Exec sp_singleFeedthroughs_two 'All','All','NO','YES','Copper Fixed','4','All'

Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'NO'.
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'None'.
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name '4'.
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'Copper Fixed'.
Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'YES'.

The Procedure is as follows:

CREATE PROC sp_singleFeedthroughs_two
(@kvs varchar(10),
@amps varchar(10),
@weldTerm varchar(10),
@flangeTerm varchar(10),
@flangeType varchar(20),
@feedTHQty varchar(10),
@conductor varchar(10))

as
DECLARE @myWhere varchar(900)

if ((@kvs = 'All') AND (@amps = 'All') AND (@conductor = 'All'))
begin
SELECT @myWhere = 'WHERE wterm = "' + @weldTerm + '" AND ' +
'fterm = "' + @flangeTerm + '" AND ' +
'flgt = "' + @flangeType + '" AND ' +
'feedq = "' + @feedTHQty + '" AND ' +
'condt != "None" '

end
else

begin
SELECT @myWhere = 'WHERE kv ="' + @kvs + '" AND ' +
'amp ="' + @amps + '" AND ' +
'wterm ="' + @weldTerm + '" AND ' +
'fterm ="' + @flangeTerm + '" AND ' +
'flgt ="' + @flangeType + '" AND ' +
'condt = "' + @conductor + '" AND ' +
'feedq ="' + @feedTHQty + '" '
end


EXEC ('SELECT * FROM Single_Feedthroughs_vw ' + @myWhere)

All the column names in the view are exactly correct.

Any Ideas ??

Cheers in advance..

Paul.
 

Add SET QUOTED_IDENTIFIER ON at the beginning of your query or replace the double quotes with two single quotes.

'WHERE wterm = ''' + @weldTerm + ''' AND ' Terry L. Broadbent
Life would be easier if I had the source code. -Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top