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
 RPAD /LPAD function

Author  Topic 

shifis
Posting Yak Master

157 Posts

Posted - 2006-03-08 : 20:05:00
Hi
I do the next SP, but when I try to run I got an error

Line that I try to run in Query analyzer:
exec SP_RPAD('tere',7,'W')
Error:
Line 3: Incorrect syntax near 'tere'.

Procedure

CREATE PROCEDURE SP_RPAD
@Cadena varchar(200), --Cadena Original a la que se va a rellenar
@LongCadena int, --Longuitud final que tendra la cadea
@Char_llenar char(1) --Caracter con el que se va a rellenar
AS

SELECT RIGHT(REPLICATE(@Char_llenar,@LongCadena) + @Cadena ,@LongCadena) AS RPAD
GO


Any idea what I am doing wrong?

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2006-03-08 : 20:49:09
You don't need the parentheses on your proc call.

i.e. exec SP_RPAD 'tere',7,'W'



Damian
"A foolish consistency is the hobgoblin of little minds." - Emerson
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-03-08 : 20:51:13
New to stored procedures? Don't enclose the parameter list in parentheses.

exec SP_RPAD 'tere',7,'W'


CODO ERGO SUM
Go to Top of Page

shifis
Posting Yak Master

157 Posts

Posted - 2006-03-09 : 10:31:56
Thanks, I have a very long time with out using SQL server, so how you can see I'm starting to foget the sintaxis
Go to Top of Page
   

- Advertisement -