How can two strings be concatenated?

paste() is the way to go. As the previous posters pointed out, paste can do two things: concatenate values into one “string”, e.g. > paste(“Hello”, “world”, sep=” “) [1] “Hello world” where the argument sep specifies the character(s) to be used between the arguments to concatenate, or collapse character vectors > x <- c(“Hello”, “World”) … Read more

Shortcuts in Objective-C to concatenate NSStrings

An option: [NSString stringWithFormat:@”%@/%@/%@”, one, two, three]; Another option: I’m guessing you’re not happy with multiple appends (a+b+c+d), in which case you could do: NSLog(@”%@”, [Util append:one, @” “, two, nil]); // “one two” NSLog(@”%@”, [Util append:three, @”https://stackoverflow.com/”, two, @”https://stackoverflow.com/”, one, nil]); // three/two/one using something like + (NSString *) append:(id) first, … { NSString … Read more

nvarchar concatenation / index / nvarchar(max) inexplicable behavior

TLDR; This is not a documented/supported approach for concatenating strings across rows. It sometimes works but also sometimes fails as it depends what execution plan you get. Instead use one of the following guaranteed approaches SQL Server 2017+ SELECT @a = STRING_AGG([msg], ”) WITHIN GROUP (ORDER BY [priority] ASC) FROM bla where autofix = 0 … Read more

How to create a SQL Server function to “join” multiple rows from a subquery into a single delimited field? [duplicate]

If you’re using SQL Server 2005, you could use the FOR XML PATH command. SELECT [VehicleID] , [Name] , (STUFF((SELECT CAST(‘, ‘ + [City] AS VARCHAR(MAX)) FROM [Location] WHERE (VehicleID = Vehicle.VehicleID) FOR XML PATH (”)), 1, 2, ”)) AS Locations FROM [Vehicle] It’s a lot easier than using a cursor, and seems to work … Read more

How to use GROUP BY to concatenate strings in SQL Server?

No CURSOR, WHILE loop, or User-Defined Function needed. Just need to be creative with FOR XML and PATH. [Note: This solution only works on SQL 2005 and later. Original question didn’t specify the version in use.] CREATE TABLE #YourTable ([ID] INT, [Name] CHAR(1), [Value] INT) INSERT INTO #YourTable ([ID],[Name],[Value]) VALUES (1,’A’,4) INSERT INTO #YourTable ([ID],[Name],[Value]) … Read more

I had issue in below mention program to assign a value to the pointer.String concatenation Program( *s1=*s2) [closed]

So you are getting access voilation…. The problem is that your buffers are probably overflowing and you have no length check in your code… The buffers you have allocated are only 25 bytes long char str1[25], str2[25]; so to intruduce a length check, add an extra parameter to concat which tells how long the output … Read more