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 2008 Forums
 Transact-SQL (2008)
 String Concatenation seems to adopt shorter string

Author  Topic 

mmccardle
Starting Member

43 Posts

Posted - 2012-03-06 : 16:12:01
I'm trying to concatenate two database table fields using the '+' operator. One field is an NVARCHAR(40), the other is NVARCHAR(255). Every way I try to combine the two fields, the result is always 40 characters. How do you concatenate two fields without this limitation?

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-06 : 16:21:35
want to post your code?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-06 : 16:23:31
I don't know what you are doing, but this works


DECLARE @x NVARCHAR(40), @y NVARCHAR(255)
SELECT @x = REPLICATE('x',40), @y = REPLICATE('y',255)
SELECT LEN(@x + @y), @x + @y



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

mmccardle
Starting Member

43 Posts

Posted - 2012-03-06 : 16:36:11
Nevermind, it was a problem in the Crystal Report :)
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-06 : 20:49:04
and not for nuthin..BUT..have Crystal go against VIEWS or Stored Procedures



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -