解释一下:CREATE trigger test_trigger on test_table for insert as update test_table set name =substring('FM'+stuff('00000',5-len(i.id)+1,len(i.id),CAST(i.id AS char(5))),1,7) from inserted i where i.id=test_table.id GO
时间: 2023-05-17 15:03:18 浏览: 47
这是一个 SQL Server 的触发器,当 test_table 表中插入新数据时,会触发 test_trigger 这个触发器。触发器会将插入的数据的 id 字段转换成一个以 FM 开头,总共 7 位的字符串,并更新 test_table 表中对应的记录的 name 字段。具体的转换过程是:将 id 转换成一个长度为 5 的字符串,不足 5 位的在前面补 0,然后将这个字符串插入到 FM 的后面,最后截取前 7 位作为 name 字段的值。
相关问题
std::vector<std::string> substring_2;转为string
将一个 `std::vector<std::string>` 转换为一个 `std::string` 可以通过使用一个循环遍历每个元素,然后将它们拼接起来。代码示例如下:
```
#include <iostream>
#include <vector>
#include <string>
int main() {
std::vector<std::string> substring_2{"hello", "world", "!"};
std::string result;
for (const auto& str : substring_2) {
result += str;
}
std::cout << result << std::endl;
return 0;
}
```
输出结果为:`helloworld!`。
std::vector<std::string> substring_2 输出第三到第五的结果
std::vector<std::string> substring_2 是一个存储字符串的向量,你想要获取其中第三到第五个字符串的结果。假设向量中有n个字符串,那么第三到第五个字符串的索引分别是2、3和4(索引从0开始计数)。因此,你可以通过以下方式获取结果:
substring_2:获取第三个字符串
substring_2:获取第四个字符串
substring_2:获取第五个字符串
请注意,这些索引是基于向量的实际元素位置,而不是从1开始计数。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)