【发布时间】:2017-02-24 04:48:22
【问题描述】:
这是我从 powershell 中提取并插入到#temptable 中的数据:
Name : SULESRKMA
Location : Leisure Services - Technology Services
Shared : False
ShareName :
JobCountSinceLastReset : 0
PrinterState : 131072
Status : Degraded
Network : False
我正在遍历数据并从标识符中删除了值。我想使用这些标识符将值插入到具有与标识符相同的列名的表中。例如,我有一个名为@identifier = "Name" 的变量和一个列名为Name 的临时表#printers。我想做类似的事情:
SELECT --select statement
INSERT INTO #printers(@identifier)
但这并不奇怪,这似乎不起作用。有没有办法做到这一点? (@identifier 变量将在整个 while 循环过程中更改为数据中的其他标识符。)
欢迎任何甚至不涉及使用这种方法的替代建议。我的最终目标只是将这些数据作为一行放入表格中。
(如果这很重要,我目前正在使用 Microsoft SQL Server Management Studio)
【问题讨论】:
标签: sql-server database tsql powershell printers