发表以下最新声明。
UPDATE TABLE_1
SET Units2 = ABS(Units1)
,Dollars2=ABS(Dallars1)
,Units1 =0
,Dollars1 =0
WHERE Units1 < 0
AND Dollars2 = 0
我的问题是:
(1) 这是否合法? 它禁止并“种子”工作(在试验桌上),但总是工作,或者我只是拿正确的记录来审查。
2)这是更好的办法。
感谢
发表以下最新声明。
UPDATE TABLE_1
SET Units2 = ABS(Units1)
,Dollars2=ABS(Dallars1)
,Units1 =0
,Dollars1 =0
WHERE Units1 < 0
AND Dollars2 = 0
我的问题是:
(1) 这是否合法? 它禁止并“种子”工作(在试验桌上),但总是工作,或者我只是拿正确的记录来审查。
2)这是更好的办法。
感谢
它是合法的,只要你想要基本上保留<代码>Units1和Dollars1
在
Units2
和_Dollars2
上的旧价值,就应当工作。
试验:
CREATE TABLE #Table_1
(
Units1 INT,
Dollars1 MONEY,
Units2 INT,
Dollars2 MONEY
)
GO
INSERT INTO #Table_1 (Units1, Dollars1, Units2, Dollars2)
VALUES (-1,12.00,3,0.00)
GO
UPDATE #TABLE_1
SET Units2 = ABS(Units1)
,Dollars2=ABS(Dollars1)
,Units1 =0
,Dollars1 =0
WHERE Units1 < 0
AND Dollars2 = 0
GO
SELECT *
FROM #Table_1
产出:
Units1 | Dollars1 | Units2| Dollars2
0 | 0.00 | 1 | 12.00
假设你再谈论美元1栏,我认为这应该罚款。 阅读时应当使用现值,在计算后进行书写。
如果你现在再次问这个问题,但我建议将其分为两场发言。 你回过提交人,对你来说不很清楚。 在必须维持的伪装上一点点,现在就清楚这一点。
你的问询是正确的,在很大程度上是这样做的方法。
I ve got two tables: TableA Col1 Col2 TableB Col3 Col4 I want to join them together: SELECT * from TableA join TableB ON (...) Now, in place of ... I need to write an expression ...
TSQL query to select all records from Customer that has an Order and also select all records from customer that does not have an Order. The table Customer contains a primary key of CustomerID. The ...
I have a stored procedure which takes an XML parameter and inserts the data into multiple tables. If I run the stored procedure into a database using a SSMS query window, everything works fine. ...
Have a win 2003 box with MSSQL 2005 running on it. There is a database which is populated every morning with new/modified SalesOrder made the previous day. The database has several tables: SalesOrder, ...
I have a table with the following fields Id Name IsPublic i need to write a sql query that updates IsPublic to false where name has a duplicate. Only one of the duplicates should have IsPublic = ...
I have a Transact-SQL query that uses the IN operator. Something like this: select * from myTable where myColumn in (1,2,3,4) Is there a way to define a variable to hold the entire list "(1,2,3,4)"? ...
I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...
I m trying to transform the SQL Query below into Linq to SQL select Categorias.IdCategoria, Categorias.Nome, SUM(lancamentos.valor) from lancamentos left outer join Categorias on Lancamentos....