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
 General SQL Server Forums
 New to SQL Server Programming
 email error

Author  Topic 

parry02
Starting Member

18 Posts

Posted - 2006-04-20 : 08:55:54
I am trying to trigger an e-mail from a another application and
i have this code which is executed - but on execution
of the code I am getting the following error ....


[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid length parameter passed to the substring function.

This is the code :
SET NOCOUNT ON

DECLARE @pos INT

SELECT @pos = CHARINDEX(',','{payment_emailaddress}')

SET NOCOUNT OFF

IF @pos > 1
BEGIN
SELECT SUBSTRING('{payment_emailaddress}', 1, CHARINDEX(',','{payment_emailaddress}')-1) AS email
END
ELSE
BEGIN
SELECT '{payment_emailaddress}' AS email
END


Many thanks if anyone can help me out .....

druer
Constraint Violating Yak Guru

314 Posts

Posted - 2006-04-20 : 09:22:33
Where is the {payment_emailaddress} coming from? As it looks it is just a hard coded value in quotes.

Go to Top of Page

parry02
Starting Member

18 Posts

Posted - 2006-04-20 : 09:29:45
its coming from an ACCESS system
Go to Top of Page

druer
Constraint Violating Yak Guru

314 Posts

Posted - 2006-04-20 : 09:32:40
This looks like a pass-thur query since you are setting NOCOUNT, so how will SQL Server know what the value is?
Go to Top of Page
   

- Advertisement -