来自特定列的Concat字符串和新的字符串值SQL Server CE

时间:2015-03-13 20:26:12

标签: c# sql database visual-studio-2012 sql-server-ce

我有一个名为events的表,我无法在列包含数据信息的地方更新它,我试图将字符串附加到特定列 这是我试过的查询。

VolunteerEvents表中的列,并且该行

 UPDATE Events 
 SET Volunteers = Volunteers + @Volunteers +'\n'  
 WHERE Event_Name = @Event_Name

 UPDATE Events 
 SET Volunteers += @Volunteers +'\n'  
 WHERE Event_Name = @Event_Name

尝试了两种方式,但都没有。

例如,列包含“abc”,并从参数“123”

添加另一个

所以看起来像这样

 abc
 123
数据库中的

假设看起来像这样

我正在使用带有SQL Server CE数据库的Visual Studio(Windows窗体应用程序)。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

        Try Using CHAR(13)

        see I explain 

        Declare @TableField varchar(50)
        Declare @Volunteers varchar(50)
        Declare @Result varchar(50)

        SET @TableField = 'abc'
        SET @Volunteers = '123'

        SET @Result= @TableField+CHAR(13)+@Volunteers

        SELECT @Result AS Result

        OUTPUT Paste Then like 

        abc
        123

        either char(13) or char(10) would work. 

        but ,char(10) = \n - new line
             char(13) = \r - go to the beginning of the line

        You Set On  Query AS 

         UPDATE Events 
         SET Volunteers = Volunteers+CHAR(13)+@Volunteers
         WHERE Event_Name = @Event_Name