I'm trying to insert into another column the database name from the TEXT column return by the following query, which was inserted into another table:
EXEC master..sp_readerrorlog 0,1,"Database backed up. Database:"
which returns
Database backed up. Database: databaseName, creation date(time): 2014/06/13(17:49:54), pages dumped: 197581, first LSN: 488:6298:36, last LSN: 488:6314:1, number of dump devices: 4, device information: ...
Following recomandations of other posts from here, I wrote:
SUBSTRING([TEXT], LEN(LEFT([TEXT], CHARINDEX (': ', [TEXT]))) + 1, LEN([TEXT]) - LEN(LEFT([TEXT],
CHARINDEX (': ', [TEXT]))) - LEN(RIGHT([TEXT], LEN([TEXT]) - CHARINDEX (', ', [TEXT]))) + 1)
as DatabseName
which returns
'DatabaseName,' keeping the comma
I've tried to alter both CHARINDEX parameter '+1' without success.
Anybody has an idea on how to get rid of that comma ?