Write to the same table of zishu fields
CodePudding user response:
This kind of circumstance should use the computed columns, rather than repeatedly updating,Because you never know when someone to insert or modify,
USE tempdb for
GO
IF OBJECT_ID (" article ") IS NOT NULL
DROP TABLE article
GO
The CREATE TABLE article (
[content] NVARCHAR (200)
)
GO
- note: insert have a carriage return and line feed
INSERT INTO article ([content]) VALUES (' ABC zhang 123
Li si '
);
-- -- -- -- -- -- -- -- above for testing table and test data -- -- -- -- -- -- -- -- --
- 1. Add computed columns
The ALTER TABLE article ADD zizhu AS LEN (REPLACE (REPLACE ([content], CHAR (10), ' '), the CHAR (13), "));
GO
- 2. Query
SELECT * FROM article