Vic*_*ues 6 sql linq sql-server
我有用于编辑表数据的MS SQL Management Studio,它没有很好的可用性.我需要像在Excel中一样编辑几百行,能够将列排序到简单的编辑过程(SQL Mgmt只有'Open table'功能,没有排序列,只有使用UPDATE SQL代码才能进行更新).
LinqPad很棒,但仅限于查询.我想编辑表格结果.
我安装了Acqua Studio,它拥有一切,但试用期已过期.你知道任何可以做到这一点的软件免费替代品吗?
编辑:我真的需要改变和输入数据,当然我可以通过SQL代码来完成它,但是当你必须手动更新大量的行时它并不快.我需要一个可编辑的有序网格.我将尝试MSManager Lite.
谢谢
我把这个工具永久地放在USB记忆棒上 - 真的非常适合免费的"精简版"(也有专业版)
http://sqlmanager.net/products/mssql/manager
它是一个单一的整体exe,非常适合移植性.
我建议学习必要的SQL来更新表中的相应数据.您可以将SELECT语句与ORDER BY子句一起使用,以按照您希望查看的顺序查看数据,然后构建查询以更新该数据.
您可以使用事务来确保您的更新是正确的(如果您仍在学习SQL并且不想弄乱数据库).
BEGIN TRANSACTION -- starts a transaction
ROLLBACK -- stops the transaction and rolls back all changes to the tables
COMMIT -- stops the transaction and commits all changes to the tables
Run Code Online (Sandbox Code Playgroud)
你想要完成/更新什么,也许我们可以帮助你?
编辑
您提到要编辑存储在表中的某些产品名称.而且这将是一次性任务.我在下面设置了一个小型演示,希望能帮助您找到适合您情况的解决方案.将其复制并粘贴到SQL Management Studio会话中.
此外,如果需要,可以将当前数据导出为excel,在excel中编辑该数据,将其作为新临时表导入,并运行SQL更新脚本以更新原始表.
/*
Products Before Update Products After Update
=========================== =============================================
ID ProductName ID ProductName
--------------------------- ---------------------------------------------
1 MSFT 1 Microsoft Corp.
2 APPL 2 Apple Inc.
3 Cisco Systems, Inc. 3 Cisco Systems, Inc.
4 IBM 4 International Business Machines Corp.
5 JAVA 5 Sun Microsystems, Inc.
6 ORCL 6 Oracle Corp.
*/
-- Imagine that this table is a table in your database
DECLARE @products TABLE (
ID INT,
ProductName VARCHAR(255)
)
-- And this table has some product information
-- which you are trying to update with new information
INSERT @products
SELECT 1, 'MSFT' UNION ALL
SELECT 2, 'APPL' UNION ALL
SELECT 3, 'Cisco Systems, Inc.' UNION ALL
SELECT 4, 'IBM' UNION ALL
SELECT 5, 'JAVA' UNION ALL
SELECT 6, 'ORCL'
-- Either build an in-memory temporary table of the product names you wish to update
-- Or do a database task to import data from excel into a temporary table in the database
DECLARE @products_update TABLE (
ID INT,
ProductName VARCHAR(255)
)
INSERT @products_update
SELECT 1, 'Microsoft Corp.' UNION ALL
SELECT 2, 'Apple Inc.' UNION ALL
SELECT 4, 'International Business Machines Corp.' UNION ALL
SELECT 5, 'Sun Microsystems, Inc.' UNION ALL
SELECT 6, 'Oracle Corp.'
-- Update the table in the database with the in-memory table
-- for demo purposes, we use @products to represent the database table
UPDATE p1
SET ProductName = ISNULL(p2.ProductName, p1.ProductName)
FROM @products p1
LEFT JOIN @products_update p2
ON p1.ID = p2.ID
-- Now your products table has been updated
SELECT *
FROM @products
Run Code Online (Sandbox Code Playgroud)