473,508 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Moving Data from right to left SQL

9 New Member
Apologies if the title is a bit abstract, but it was hard to put into a single title what I am trying to achieve.

I have a table called PTYP and columns named PTYPNR, STAB1, STAB2, STAB3.......to STAB10

In some of the records one of the STAB columns (could be any of them) can have an entry of 1659 what I am trying to do is delete this entry but then move the values in the columns to the right 1 to the left

e.g Say the existing record layout is
PTYP STAB1 STAB2 STAB3 STAB4 STAB5............ STAB10
1 400 300 1659 700 0 0
should become
1 400 300 700 0 0.............. 0

what I am getting is
1 400 300 300

I am using the following query

update protel.ptyp set
[stab1]= case when [stab1]=1659 then [stab2] else [stab1] end
,[stab2]= case when [stab2]=1659 or [Stab2]= [stab1] then [stab3] else [stab2] end
,[stab3]= case when [stab3]=1659 or [Stab3]= [stab2] then [stab4] else [stab3] end
,[stab4]= case when [Stab4]=1659 or [Stab4]= [stab3] then [Stab5] else [Stab4] end
,[Stab5]= case when [Stab5]=1659 or [Stab5]= [stab4] then [Stab6] else [Stab5] end
,[Stab6]= case when [Stab6]=1659 or [Stab6]= [stab5] then [Stab7] else [Stab6] end
,[Stab7]= case when [Stab7]=1659 or [Stab7]= [stab6] then [Stab8] else [Stab7] end
,[Stab8]= case when [Stab8]=1659 or [Stab8]= [stab7] then [Stab9] else [Stab8] end
,[Stab9]= case when [Stab9]=1659 or [Stab9]= [stab8] then [Stab10] else [Stab9] end
,[Stab10]= case when [Stab10]=1659 or [Stab10]= [stab9] then 0 else [Stab10] end


Can anyone provide the correct code?
thank you
Nov 27 '08 #1
0 867

Sign in to post your reply or Sign up for a free account.

Similar topics

2
10432
by: KalleD | last post by:
Why can I not move the windows taskbar with the SHAppBarMessage function? I am able to use the function for hiding it and other things, but not moving it (I have unchecked the lock). The code is...
0
984
by: Voast | last post by:
I have a basic Form. This form is mainly for displaying basic real-time data. I want to insure that is a user moves the windows to the right or left of the WorkingArea bounds that the window...
1
1402
by: cricketunes | last post by:
Hey folks I am implementing the Huffman encoding algorithm. I have created the tree and its perfect. Now while searching for a node value, I need to write a 0 to the encoded file if I am moving...
0
1399
by: Jeff Waskiewicz | last post by:
Here is what I am trying to accomplish. I have an MDI application on the left side of the client area I have a borderless form that holds a treeveiw for navigation. When an item is selected from...
5
2499
by: niklaus | last post by:
Hi, I have an array in which elements are present . The number of elements n <= 10^6 . Now if i delete an element in the array, i want to update the array by moving all the elements to the...
3
3274
by: Cartoper | last post by:
I would like to design a web page as follows: There is a box (box A) with some things in it that the user can click on. When an item is clicked, another box (box B) moves in from the right side...
10
6736
by: cjparis | last post by:
Hello everyone. If anyone can give me a hand I would be gratefull Am doing a site which requires a moving element and have used DHTML to do it. Have a simple Browser detect script to sort IE...
1
3778
by: rsteph | last post by:
I bought a book to help me learn to use DirectX with windows programming. It's first trying to walk me through some basic windows programming and graphics before getting into DirectX. I'm trying to...
15
2417
by: mcjason | last post by:
I saw something interesting about a grid pair puzzle problem that it looks like a machine when you find each that work out the way it does and say with all the others that work out the way they...
1
3863
colinod
by: colinod | last post by:
Hi everyone i am trying to make a page that goes to the next recorset when i click on a button so the page only shows one record at a time, this is for updating so i need to be able to go to the...
0
7229
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7129
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7333
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.