SQL query: Pull data in null column

15 pts.
Tags:
SQL
SQL queries
I have a table with 4 columns. Two have data in it with margin record and not mar. The other two col is null. I need to put data in null column that mar.
RecA	RealRecord	RecB	misRecors
2345		        2345	
2456		        2346	
3456		        3456	
4567		        4568	
 
							


Software/Hardware used:
MICROSOFT SQL SERVER
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    What data do you need to put in the null columns and where is it coming from? Post your code and we sill take a look.
    131,605 pointsBadges:
    report
  • GK2013
    The data is in one table called Test, with four Columns two Columns has data that are merging and not merging in both Columns. I need to create a query that will compare bothColumns--A and Columns B and insert the the merging record and non merging in the two Null columns. so you can selected RealRecord field for merging record and misRecors field for non merging record.

    DECLARE @RecA float
    DECLARE @RecB float


    DECLARE UpdateRecords CURSOR FOR (SELECT S.RecA, S.RecB FROM Sheet1$ S)
    OPEN UpdateRecords
    FETCH NEXT FROM UpdateRecords INTO @RecA,@RecB

    WHILE @@FETCH_STATUS = 0 BEGIN
    IF(@RecA = @RecB)BEGIN
    UPDATE Sheet1$ SET RecAB = @RecA WHERE RecAB IS NULL
    END
    ELSE BEGIN
    UPDATE Sheet1$ SET RecBA = @RecA WHERE RecBA IS NULL
    END
    FETCH NEXT FROM UpdateRecords INTO @RecA,@RecB
    END
    CLOSE UpdateRecords
    DEALLOCATE UpdateRecords
    15 pointsBadges:
    report
  • ToddN2000
    Two questions. Where is RecAB defined? Where is the merge?
    131,605 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: