MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old September 12th, 2004, 07:58 PM
confuzed2xover confuzed2xover is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 185 confuzed2xover User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 45 m 53 sec
Reputation Power: 5
Question Move Data From one column to another in same table

Okay, after I got everything imported, I found that a few thousand columns had "Shifted" on me. So now I am trying to "Shift them over" to where they need to be.

I did this:
INSERT INTO dbo.TABLENAME (COLUMN_NAME_TO_BE POPULATED)
SELECT COLUM_NAME_OF_INFO_TO_BE_MOVED
FROM dbo.TABLENAME
WHERE MFG = 'MANUFACTURER_NAME' AND PN LIKE '8888888888'
GO

I populated the PN column with 8888888888 to use as a reference point, and the MFG column already was populated with the correct name, so I was using those as my unique reference points.

Other columns that have the same MFG name are correct, so I have to use two unique identifiers to specify the actual data that needs to be moved.

It inserted 'NULL' in the whole table after I ran it in the Query Analyzer. It appeared to disregard the WHERE statement all together
Any ideas on what I am doing wrong here?

Is there a way to move the data from one column to the next one over by specifying other WHERE criterias?

Reply With Quote
  #2  
Old September 12th, 2004, 08:34 PM
confuzed2xover confuzed2xover is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 185 confuzed2xover User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 5 h 45 m 53 sec
Reputation Power: 5
Ask a stupid question and the answer slaps you in the face

Well, it was good to get the question out there, now here is the solution I did that worked:

SELECT COLUM_NAME_OF_INFO_TO_BE_MOVED
FROM dbo.TABLENAME
WHERE MFG = 'MFG_NAME'AND PN LIKE'8888888888'
UPDATE dbo.BELLCORE
SET COLUMN_NAME_TO_BE POPULATED = COLUM_NAME_OF_INFO_TO_BE_MOVED
WHERE MFG = 'MFG_NAME'AND PN LIKE'8888888888'
GO

I checked the results and it worked like I wanted, I think. SO far so good....... Thank you all for being the sounding board for frustrating moments.............

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Move Data From one column to another in same table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway