473,408 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

I want to separate the column data into two columns

Hi All,

I have a table in sql server with some tables.
And in that,one of the column on one table has the data like shown in figure 1.

Now i want to separate(or)split in to two columns like shown in the figure 2.

so could any one please provide the query for getting my required output.

Thanks In Advance,
Phani Kumar.
Attached Images
File Type: png Figure 1.png (8.4 KB, 119 views)
File Type: png Figure 2.png (8.8 KB, 120 views)
Sep 3 '14 #1
3 1292
Rabbit
12,516 Expert Mod 8TB
Use the RIGHT() function to get the last 10 characters and the LEFT() function with the LEN() function to get the left x characters where x is equal to th length returned from LEN() minus 11.
Sep 3 '14 #2
Thank you Rabbit for your information.
what you are suggested me is that fine only the pincode has 10 characters(from Right to Left).

so if any of the address has lessthan or greaterthan the 10 characters how i will separate.

Please suggest me and Please provide me the query for both types(If the pincode characters are in static state means 10 characters and the second type is,the pincode characters are in dynamic state means lessthan or greaterthan the 10 characters)


Thanks In Advance,
Phani Kumar.
Sep 4 '14 #3
jforbes
1,107 Expert 1GB
Hello Phani Kumar,

Building on what Rabbit has supplied you with, you could build a couple functions like this to separate the Address by its Last Space:

Expand|Select|Wrap|Line Numbers
  1. Public Function getAddressWithoutPin(ByRef sAddress As String) As String
  2.     getAddressWithoutPin = Left(sAddress, InStrRev(sAddress, " ") - 1)
  3. End Function
  4.  
  5. Public Function getAddressPin(ByRef sAddress As String) As String
  6.     getAddressPin = Right(sAddress, Len(sAddress) - InStrRev(sAddress, " "))
  7. End Function
  8.  
Then if I understand your post correctly, you need to see the results in a select. With the given information, this is the closest I could manage:

Expand|Select|Wrap|Line Numbers
  1. SELECT getAddressWithoutPin([Address]) AS JustAddress, getAddressPin([Address]) AS Pin FROM YourTable;
Sep 4 '14 #4

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

Similar topics

10
by: sffan | last post by:
I am new to database programming and was curious how others solve the problem of storing encrypted in data in db table columns and then subsequently searching for these records. The particular...
2
by: bissatch | last post by:
If I want to determine what data types a table has, how would I do this using PHP? I tried looking into SHOW TABLES but would I be correct in saying that just displays a list of tables? I want...
3
by: David M | last post by:
When using a dataset, how can one get to a column data element using this format: dataset.Tables.Rows.... I can get to a specific row, but I am not sure how to get to the column or data. I...
2
by: kc68 | last post by:
I'm trying to import a csv spreadsheet into Access and find that the data in some cells in a few rows gets pushed to columns to the right. When I reach the point in the Wizard that shows the column...
1
by: marsha | last post by:
i have problem with my script. i have input from several sensor then i send to serial port. the serial data received with vb. data appear not in a single data, but in some packet. so, how to...
2
by: bogie | last post by:
Hello I have some problem to change my column data type in my table property from character(15) to character(100). I use Postgresql 7.4. The problem is I try to make new column with...
3
by: ncsthbell | last post by:
I am trying to run a query in access using the 'max' function. For example, I have many rows of data, one for each state and each state has a column for 'Miles'. I want to get the highest number of...
4
by: samitasahu | last post by:
Hi, I m showing College Details in a table in jsp . I want to transpose the column data into rows in the table. How to do that in jsp coding.
2
by: canoewhiteh2o | last post by:
I am having trouble adding data columns to a disconnected database. I first load a datatable using: private DataTable dtMacros = new DataTable(); private ArrayList macro = new ArrayList();...
0
by: naveendb2dba | last post by:
while loading the PK COLUMN data into table I am getting the duplicate key in a table because of PK COLUMN having auto increment. My requirement is what ever data having the ORIGINAL TABLE that...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.