我有一个名为events
的表,我无法在列包含数据信息的地方更新它,我试图将字符串附加到特定列
这是我试过的查询。
Volunteer
是Events
表中的列,并且该行
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窗体应用程序)。
有什么建议吗?
答案 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