Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 The return of Weird parameter passing

Author  Topic 

srad
Starting Member

39 Posts

Posted - 2001-08-17 : 12:00:16
Yesterday i posted an article (check out Weird parameter passing) asking why i didn't need to pass parameters with single quotes between sp's. JohnDeree was my saviour, explaining that i was passing a variable and not an implicit string.

However i have been working on another sp today and i have discovered some irregularity.
This sp receives an input param which i use in the WHERE clause of my SELECT statement.

-- This does not work
create proc usp_sp1
@param as varchar(10)
AS
SELECT [cols]
FROM [table]
WHERE col1 LIKE @param + '%'

-- This does
create proc usp_sp1
@param as varchar(10)
AS
SELECT [cols]
FROM [table]
WHERE col1 LIKE char(39) + @param + '%' + char(39)

As far as i can tell i am passing @parm1 as a variable so why do i need the single quotes
this time?

   

- Advertisement -