Update from Sync Service

This commit is contained in:
FNS Service
2026-04-21 17:41:25 +08:00
parent f282f6363f
commit 65f16fe48c
245 changed files with 5459 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
--声明一个变量
```sql
declare @tbname as nvarchar(100);
```
--声明一个游标用来遍历查询到的结果
```sql
declare C_userID CURSOR for
select distinct TABLE_NAME from information_schema.COLUMNS
where TABLE_NAME like '%_clean'
```
--打开游标
```sql
open C_userID;
```
--获取游标指向的数据
```sql
fetch next from C_userID into @tbname;
while @@FETCH_STATUS = 0
```
BEGIN
--执行具体的操作
--创建非聚集索引
--create NONCLUSTERED INDEX 索引名称 ON 表名(字段名)
EXEC('create NONCLUSTERED INDEX '+'IX_'+@tbname+ ' ON '+@tbname+ '([Style] ASC,[aDatetime] DESC)')
--游标指向下一条数据
```sql
FETCH next from C_userID into @tbname;
```
END
--关闭游标
CLose C_userID
--释放游标
DEALLOCATE C_userID;
--声明一个变量
```sql
declare @tbname as nvarchar(100);
```
--声明一个游标用来遍历查询到的结果
```sql
declare C_userID CURSOR for
select distinct TABLE_NAME from information_schema.COLUMNS
where TABLE_NAME like '%_2020_APP'
```
--打开游标
```sql
open C_userID;
```
--获取游标指向的数据
```sql
fetch next from C_userID into @tbname;
while @@FETCH_STATUS = 0
```
BEGIN
--执行具体的操作
--创建非聚集索引
--create NONCLUSTERED INDEX 索引名称 ON 表名(字段名)
EXEC('create NONCLUSTERED INDEX '+'IX_'+@tbname+ ' ON '+@tbname+ '([DeviceId] ASC,[CollectTime] DESC)')
--游标指向下一条数据
```sql
FETCH next from C_userID into @tbname;
```
END
--关闭游标
CLose C_userID
--释放游标 DEALLOCATE C_userID;