I have two tables in my SQL Server
Table no. one
CREATE TABLE
Table no. 2
CREATE TABLE #Data ( decQuantity DECIMAL(18, 2) , decClosing DECIMAL(18, 2) , varInvalidRemarks VARCHAR(MAX) ) INSERT INTO #Data (decQuantity, decClosing) VALUES (10.10, 25.00), (-15.10, 45.00), (5.10, -10.00), (-25.10, -10.00)
From these two tables, I want to update the #Data table varInvalidRemarks , and I need the following output:
decQuantity | decClosing | varInvalidRemarks -------------|------------|-------------------------- 10.10 | 25.00 | -15.10 | 45.00 | Consumed (Strips) can NOT be negetive 5.10 | -10.00 | Closing (Strips) can NOT be negetive -25.10 | -10.00 | Consumed (Strips) can not be negetive,Closing(Strips) can not be negetive
I did this thing with the FAST FORWARD READ ONLY cursor, but I want to do this with a subquery or a dynamic query.
DECLARE @varColumnName VARCHAR(200) , @varAliasName VARCHAR(200) DECLARE DisplayColumn CURSOR FAST_FORWARD READ_ONLY FOR SELECT C.varColumnName , C.varAliasName FROM
I want to do this due to a performance issue in my stored procedure.
Is it possible to achieve this with a sub-query?
thanks
source share