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 2005 Forums
 Transact-SQL (2005)
 Function Trunctating Values

Author  Topic 

Arithmomaniac
Yak Posting Veteran

66 Posts

Posted - 2008-07-14 : 14:02:17
I have a table with varchar column X. I wrote a test function for it:

CREATE FUNCTION Repeat 
(@Value varchar) RETURNS varchar
AS
BEGIN
RETURN @Value
END


The output of Repeat(X) truncates the value to be one character. So if X was Bob, the output would be B.

How can I fix this?
Thanks,
Arithmomaniac


---------
Ignorance may be bliss, but knowledge is thrill.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-14 : 14:04:21
You need to provide a size for your data type. varchar(n) --> varchar(50)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-14 : 14:09:11
Refer this:-

http://sqlblogcasts.com/blogs/madhivanan/archive/2007/12/04/column-length-and-data-length.aspx
Go to Top of Page

Arithmomaniac
Yak Posting Veteran

66 Posts

Posted - 2008-07-14 : 14:15:40
Thank you. Arithmomaniac

---------
Ignorance may be bliss, but knowledge is thrill.
Go to Top of Page
   

- Advertisement -