473,401 Members | 2,139 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,401 software developers and data experts.

How to slipt the values in SQL server

Hello this is sudheer.I am learning SQLSERVER .My Table is


Org_Countryname:
india;Australia;pakistan;England;SouthAfrica;
india;Australia;pakistan;England;SouthAfrica;.Newz land;
india;Australia;pakistan;England;SouthAfrica;.Newz land;srilanka;


My table name is organisation
in my table contain below column names

Org_name, Org_Countryname,Org_Activity,Org_Secu_Id.Org_ID

my problem is if i want display first 2 countynames in Org_Countryname
means my org_Activity='Activity' then we want display the only two county names india,Australia;

if u know the answer please send the query urgently thanks for ur advanced replay
Sep 3 '07 #1
1 990
azimmer
200 Expert 100+
Hello this is sudheer.I am learning SQLSERVER .My Table is


Org_Countryname:
india;Australia;pakistan;England;SouthAfrica;
india;Australia;pakistan;England;SouthAfrica;.Newz land;
india;Australia;pakistan;England;SouthAfrica;.Newz land;srilanka;


My table name is organisation
in my table contain below column names

Org_name, Org_Countryname,Org_Activity,Org_Secu_Id.Org_ID

my problem is if i want display first 2 countynames in Org_Countryname
means my org_Activity='Activity' then we want display the only two county names india,Australia;

if u know the answer please send the query urgently thanks for ur advanced replay
Here goes a wordy pattern:
Expand|Select|Wrap|Line Numbers
  1. declare @countries as varchar(255)
  2. declare @cutoff as integer
  3. set @countries='india;Australia;pakistan;England;SouthAfrica;.Newzland;'
  4. set @cutoff=case when charindex(';',@countries)>0 then charindex(';',@countries) else len(@countries) end
  5. set @cutoff=case when charindex(';',@countries,@cutoff+1)>0 then charindex(';',@countries,@cutoff+1) else len(@countries) end
  6. select left(@countries,@cutoff) as firsttwo
  7.  
It's more understandable this way but once you see how it works it is possible to merge the lines so that you can put it right into a SELECT.
Sep 3 '07 #2

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

Similar topics

2
by: Bertrand | last post by:
Hello, I am trying to archieve the following: - copy an excel file present on the server - insert values into named ranges of the copy I am using Excel97 on my PC, the server does not have...
1
by: Programmer | last post by:
Hi All Here is my problem I'm using a SQLDataAdapter and DataSet I use the method FillSchema(myDataset, SchemaType.Source) The problem is that when i Check the default Values of the Dataset...
3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
5
by: Robert Phillips | last post by:
I have a Panel control containing a few TextBox controls. The Panel is originally enabled, I enter data into the TextBox controls. When I submit, the Panel is disabled during the PostBack and the...
3
by: Jeremy Ames | last post by:
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated...
3
by: MattC | last post by:
I have created a container class and instantiated it in one of my pages. I fill the object on page load when not on a postback. On a button click i want to do somethign with the values in that...
4
by: J | last post by:
I am editing a pre-existing view. This view is already bringing data from 40+ tables so I am to modify it without screwing with anything else that is already in there. I need to (left) join it...
2
by: =?Utf-8?B?UGhpbGlw?= | last post by:
I am attempting to insert a simple record with LinqDataSource from a ListView, however I always get a message saying "....LinqDataSource 'dataSource' has no values to insert. Check that the...
0
by: chandrasekhar | last post by:
Hi I have developed a web page with some controls. I put all of them in session variables. I passed this values in the page. When an user enter some data in form fields and click the buttton ,...
3
by: 0301102 | last post by:
Hi, I have a input parameter call DOMAIN_NAME (Example: seng.com.my), and i need slipt it into 2 word, becasue "seng" is the label and ".com.my" is the zone, so my i know how to slpit it into two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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
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...

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.