有两个数据库(SQL Server 2008)(DataA和DataB)两个数据库都有同名的表(Employee)。
DataA 中的 Employee 表有 15 列,DataB 中的 Employee 表只有 5 列。
我想在 DataB 的 Employee 表中添加缺失的列。需要一个查询从DataA的表中获取列名,并检查该列是否存在于DataB的Employee表中,然后添加该列。
我们是否需要使用 WHILE 循环将所有缺失的列从 DataA 添加到 DataB,或者我们是否有任何选项来实现此目的?
下面的查询将列出 power shell 中的 cmdlet。
get-command -CommandType cmdlet | Group-Object -Property verb
Run Code Online (Sandbox Code Playgroud)
因为我需要按降序对列数进行排序,然后按升序命名列。下面的查询没有给出预期的结果。
get-command -CommandType cmdlet | Group-Object -Property verb | Sort-Object Count, name -Descending
get-command -CommandType cmdlet | Group-Object -Property verb | Sort-Object Count -Descending | Sort-Object name
get-command -CommandType cmdlet | Group-Object -Property verb | Sort-Object Count -Descending, name
Run Code Online (Sandbox Code Playgroud)
请在 PS 中使用单个查询帮助我解决这个问题