Split Text Field - Display 1st Or 2nd Word

Sep 24, 2012

In SQL SErver 2008, I have a text column. I need to display either 2nd word in the text column or 1st word in the text column based on certain conditions.

How shall i display either 2nd word or 1st word from a text field.

View 1 Replies


ADVERTISEMENT

Replace One Word With Another In Text Field

Oct 19, 1999

I have a text field that contains multiple words. Is there a way with SQL to relace a single word with another?

for example:

FIELD : CompanyName
DATA : Microsoft Corp.
DATA : IBM Corp.
etc...
DATA : Canon Corp. of America

How can I run a routine to just REPLACE "Corp." with "Corporation" ?

Thanks for your help!
Scott

View 1 Replies View Related

Counting Of Occurrences Of A Word In A Text Field

Oct 27, 2003

Finding numbers of occurrences of a string of characters
in a column of TEXT datatype.
DDL of involved table txt:
create table txt (pk int, txtcol text) -- datatype of pk doesn't matter

declare @word varchar(80) set @word='help'
declare @pk int, @count int, @i int, @dl int, @wl int
set @wl=len(@word)
declare abc cursor for select pk from txt
where patindex('%'+@word+'%',txtcol)>0 order by pk
open abc fetch next from abc into @pk
while @@fetch_status=0
begin
select @dl=datalength(txtcol) from txt where pk=@pk
select @i=patindex('%'+@word+'%',txtcol)+@wl from txt where pk=@pk
set @count=1
while @i<@dl
begin
select @count=@count+(len(substring(txtcol,@i,8000))-
len(replace(substring(txtcol,@i,8000),@word,'')))/@wl
from txt where pk=@pk
set @i=@i+8001-@wl
end
select pk=@pk, occurrences=@count
fetch next from abc into @pk
end
close abc deallocate abc
pk occurrences
----------- -----------
1 1

pk occurrences
----------- -----------
2 2

pk occurrences
----------- -----------
3 11
Edit: as suggested-reminded by jsmith8858.

View 7 Replies View Related

Reporting Services :: Display Check Box In SSRS Within Database Field Split By A Separator?

Aug 12, 2015

I have a database field which consists of a long string of values with some separator.

Ex: Injection^!@$#Medication

in my report i have to split the string as

Injection
Medication

till here i am able to display the results but in addition to that i have to display check box against these values like below

and this string can contain any no of values ex: if we have 4 values are separated within a string then i have to display 4 check boxes against 4 results.

View 6 Replies View Related

Text Field To Display Date Parameter Chosen

Mar 26, 2008

Hi,

I'm attempting to use the following code to display either 'All' or the date value selected by the user from a Report parameter;

=iif(Parameters!FromCheckOutDateDate.Value.ToString = "[Check Out Date].[Date].[All]", "All", "From Date: " + Parameters!FromCheckOutDateDate.Value.ToString.Substring(26,10))

This is throwing an error ('#Error').

I can use the following code with no error, though its not as useful;

=iif(Parameters!FromCheckOutDateDate.Value.ToString = "[Check Out Date].[Date].[All]", "All", "Not all")

I can even use this to display the selected value (i.e. 2007-01-01);

Parameters!FromCheckOutDateDate.Value.ToString.Substring(26,10)

Why can't I use them both in my iif statement?

Can someone please help?

View 2 Replies View Related

Reporting Services :: Field Value Text Display With IIF Statement Based On Two Parameter

Jul 9, 2015

I need to set a field value based on two date time parameter's.What is the correct syntax to allow me to pass the value into the field in my SSRS expression ?

=IIf(Parameters!EndDate > Parameters!StartDate.Value, "Overdue")

View 3 Replies View Related

Split Fields And Display Query Result

Mar 21, 2007

Hi,
I'm having a problem in spliting the fields
I need to ru the following query to join two tables and getting the output as shown.

Query:
select cusl.user_name,
pmts.bill_ref_info, pmts.payee_acid, pmts.cust_acid, pmts.txn_amt,pmts.pmt_id
from cusl, pmts
where cusl.ubp_user_id = pmts.ubp_user_id and pmts.ubp_user_id= 'testinglive'

Output:
user_name bills_ref_info payee_acid cust_acid txn_amt
SAMEER ALLA0210181#123456#Amita 378902010021095 383702070051411 1.000 16318
SAMEER BARB0GNFCOM#6788990#Vikram Kalsan 378902010021095 383702070051411 1.000 16327
SAMEER BKID0000200#378902010099678#Vikram 378902010021095 383702070051411 1.000 14031
SAMEER undefined#123456789123456#Vikram 378902010021095 383702070051411 1.000 13918


Now I need to display the second field which is a #-separated field as individual fields alongwith tghe other fields that are shown on execution of the query.
Can this be done? Please guide me on this...

View 7 Replies View Related

Display First Date If Split Into A Year And Month Column?

Mar 27, 2012

How can I find the first date if the date is split into a year and month column?

I thought of using the Min function, which would work for the year column, but it would probably just return a 1 everytime in the month column.

View 2 Replies View Related

Changing Word Doc Text Using T-SQL

Sep 13, 2007



Hi,
i was checking books online and run into the sp_OAxxxx stored procs that can give us access to a OLE Object.
I am currently developing a VB.Net app that uses a word template to create word documents. So, for example ,i we suppose that the template is :
-----Template start -------
This document was created by <!_author_> on <!_date_>
-----Template end --------
then, the created document would be :
-----Created doc start -------
This document was created by justsarter on 09/13/2007
-----Created doc end --------

All the data are fetched from a database and i have to make muptiple calls to it ,not to mention opening and closing word.application object.

I wonder if that kind of text manipulation in the document can be performed on the server using an SP
Thx
theodore

View 1 Replies View Related

How Does Full Name Field Split To First Name And Last Name Field?

Oct 9, 2001

I have a table with column person_name and I want to update that table and
insert the values of different columns FIRST_NAME and LAST_NAME.

Anybody can tell me the T-SQL code to do above problem?

Thank you very much!

View 3 Replies View Related

Word Doc In Image Field Type

Feb 25, 2005

Hi,

I was wondering if someone can help me with is problem.

I have uploaded word docs to the db which is fine. The problem is viewing. I can view then as word documents but the boss does not want the files opened in word.

Is it possable to retrieve the file from from the db and put into say a textbox or lable.

I can see the letter P using this code

Dim Doc() As Byte = New Byte(Convert.ToInt32(0)) {}
Dim bytesReceived As Long = DBContent.GetBytes(0, 0, Doc, 0, Doc.Length)

Dim encoding As ASCIIEncoding = New ASCIIEncoding
lblTest.Text = encoding.GetString(Doc, 0, Convert.ToInt32(bytesReceived)).ToString

Can any help

Thanks

View 4 Replies View Related

Adding A Word To Existing Value Of A Field

Sep 17, 2007

Hi!
I want to add a word to a value if the value already exists in that field. How to do this? Please help me. In detail, i have 'id', 'name' and 'info' three columns in one Data Table. When I inserted one value to id field, if the value already exists it should add a word to that value and it should get inserted. Please help me to do this?
Thanks in advance!

View 5 Replies View Related

Searching For A Word On Each Table On Very Field

Feb 9, 2006

Hi everybody,

is it possible using SQL Server search for a word on each
table on each field?

Thanks

Fabio

View 6 Replies View Related

Criteria; Search Any Word In Field

May 26, 2004

I am trying to set up a query that will allow the user to input a string, and the search will match ANY word in that string. Currently, I have it configured so that the search will only match the exact string that the user inputs. I have google searched for the answer, but no luck yet. Any ideas?

View 9 Replies View Related

How To Search Text In A Word Document ?

Nov 24, 2005

I'm designing a Job Recruitment Website, in which the admin person searches for the right candidate for the job using certain keywords . Each jobseeker will be uploading  his CV (ms word doc) during registration .How can i search for keywords in  the word documents. I just want the candidate reference once i found keyword match in the word docs.I heard about the indexing and blobs in sql server? But dont know much about it Are these the only solutions ?Is there any better approach for this ?Any help will be greatly appreciated

View 4 Replies View Related

Using Lookup And Display Only Field As Control Field

May 25, 2006

I am not sure If I can do this with a lookup, but what I would like todo is perhaps use lookup to retrieve a control date from anunassociated table to control what date is entered in another table.For example :the main table , table 1 has many entries with a field called date_enter which is the date the record was entered.table 2 has a control_dateIf the date entered in table 1 is less than or = to the control date wewant to give the user a error message.I am thinking of using display only field and lookup to set itWould need to have the date value from the control table available tothe active table of table 1 when entering the the date_enter.However as there is no join field between the two tables am not surehow to do it. Was thinking might have to add a key field that wasallways null and in the BEFORE EDITADD EDITUPDATE section set it sothat the key would be nullAm using Informix 5 , Any help would be apprecia

View 3 Replies View Related

Find Exact Word In Full-Text Search

Oct 3, 2007

Hi,
I have the fields like this.

Session1               Session2                  Session3   Session4----------------------------------------------------------------------------------------- SQL Server-Part1    SQL Server-Part2      ASP.Net    CSS
C#                         SQL Server-Part3    ASP.Net    Javascript 
I have set the Full-Text to all the columns. For searching i wrote the below query
SELECT * FROM <TABLE NAME> WHERE CONTAINS(*,'"SQL Server-Part1"') 
My Result expectation is: The  First Record should come. But the result of the query bring the two records. It see the "SQL Server" string also. I need to find the exact word. How to do it? Please answer me as soon as possible. Ganesh. 
 

View 6 Replies View Related

How To Compare Two Word Documents Using Full Text Search?

Mar 19, 2006

can we use full text search and mining algorithms to comapre two word or text documents to find out if they are similar
please help.
thaks for reading

View 3 Replies View Related

Split A Field

Jul 23, 2005

Whats the best way to do the following?Field1 in Table1 contains numbers and characters seperated by #Examples: aaa#01, kjhkjhjh#21 and jlkjlkj#123How can I create two new fields in Table1, one containing what is tothe left of the # and the other what is to the right?Regards,Ciarán

View 4 Replies View Related

SQL 2012 :: How To Count Instances Of Each Word Throughout Comments Field Across The Table

Oct 21, 2015

I have to count the number of instances of each word in the Comments column throughout the table using SQL Server. Eg:

Row# Comments
1 I like working on SQL
2 I enjoy sleeping and like watching TV

So the output should be :

Word Count
I 2
like 2
working 1
on 1
SQL 1
.......

Any way to get this count using MS SQL?

View 5 Replies View Related

How To Split The Field In The Sql Query?

Mar 23, 2007

      I have the field LocationID (string)which has values  like
          "AZ001","AZ002","IN002","IN004"  first 2 will be always alphabets and remaining 3 will be numbers,
I want to split it  like "AZ" ," 001"
                              "AZ","002"
                              "IN" "002"
                              "IN" "004"
now i will populate dropdownlist with  unique values of "AZ" "IN"
according to  first dropdownlist how i will populate second dropdownlist?
So how to write sql query for splitting? and then populating the dropdownlist ?
 
 
 
 

View 4 Replies View Related

How To Split A Field Into Two Fields

Apr 14, 2006

I have the following fields in table A:

GL_ID| Date |GL_Name_VC | Amount Period_TI|Year_SI
===============================================
1000|31/12/2005 | Sales | -8,000.00 | 12 | 2005
===============================================
1000|06/01/2006 | Sales | -6,000.00 | 01 | 2006
===============================================
1000|20/01/2006 | Sales | 2,000.00 | 01 | 2006
===============================================
1000|28/01/2006 | Sales | -4,000.00 | 01 | 2006

The above database is running on Microsoft SQL Server 2000 and i would like to query
for a report that looks something as below:

Period | Date | GL_Name_VC | Debit | Credit| Net Change | Balance
===============================================
01 |01/01/2006|Opening Bal | 0 | 0 | 0 | 8,000
01 |06/01/2006|Sales | 0 | 6,000 | 0 | 0
01 |20/01/2006|Sales | 2,000 | 0 | 0 | 0
01 |28/01/2006|Sales | 0 | 4,000 | 8,000 |6,000


The formula for the above calculated fields are as below:

Opening Balance = carried forward balance from Year 2005
Debit = All positive amount
Credit = All negative amount
Net Change = Total Credit - Total Debit in Period 01
Balance = Total of Net Change + Opening Bal

Guys, hope someone out there can help me with the sql command for the above report?

View 4 Replies View Related

How To Split A Field Into Two Fields

Apr 11, 2006

I have the following fields in table A:

GL_ID| Date |GL_Name_VC | Amount |Period_TI|Year_SI
===============================================================
1000|31/12/2005 | Sales | -8,000.00 | 12 | 2005
===============================================================
1000|06/01/2006 | Sales | -6,000.00 | 01 | 2006
===============================================================
1000|20/01/2006 | Sales | 2,000.00 | 01 | 2006
===============================================================
1000|28/01/2006 | Sales | -4,000.00 | 01 | 2006

The above database is running on Microsoft SQL Server 2000 and i would like to query
for a report that looks something as below:

Period | Date | GL_Name_VC | Debit | Credit| Net Change | Balance
=====================================================================
01 |01/01/2006|Opening Bal | 0 | 0 | 0 | 8,000
01 |06/01/2006|Sales | 0 | 6,000 | 0 | 0
01 |20/01/2006|Sales | 2,000 | 0 | 0 | 0
01 |28/01/2006|Sales | 0 | 4,000 | 8,000 |16,000


The formula for the above calculated fields are as below:

Opening Balance = carried forward balance from Year 2005
Debit = All positive amount
Credit = All negative amount
Net Change = Total Credit - Total Debit in Period 01
Balance = Total of Net Change + Opening Bal

Guys, hope someone out there can help me with the sql command for the above report?

View 2 Replies View Related

In A Real Pinch With FreeTextBox / Paste From Word / Ntext Field In SQL2k!

Apr 10, 2005

I am in a real squeeze here.  I am working on my first ASP.NET project here and I am having some big problems with a content management aspect of this so far.  I have a freetextbox control that my users want to be able to paste out of Word and save the content to a MSSQL Database.  Well this was working great until I found out that I have a 4000 character limitation, and most of the pasted data is well over 14000 characters at least.
I've been working on these for about two weeks and just have come to a dead end.  Here's what I had before:  Form with Freetextbox that saved the information in the form to a database by calling a function in a class.vb file, the class file then called a stored procedure using parameters.  Similiarly the display page loaded with a record id, and fired off a function stored in a class file, using stored procedures and using output parameters to I could assign the returned values to label fields etc.  This has completely gone down the toilet since i had to change to text field to accomodate the larger text sizes.  I have found some resources about chunking out to the file system, but I really don't want to do that, I just want it to display the information out on a web page, and I have been scouring google for weeks!  Can someone tell me if this the wrong approach?  How do I go about storing / retrieving HTML in an ntext database field just like these forums?  I am completely stumped!

View 2 Replies View Related

Split Long Text

Nov 20, 2007

Good day,

I have a database table that is populated by bulk insert of a text file. This file is not comma delimetated and there are no line end characters, just one very long string, although the file is fixed length.

As I said I now have this long string in my SQL Server 2005 table. Is there a fast way to split this up into multiple rows?

Say for instance I have a string of 100 characters and each row would be made up of 10 characters. Is there a easy way to split this into the 10 rows or 10 characters using just a SQL statement?

Please can someone help.
Thanks

View 12 Replies View Related

Transact SQL :: Return Field When A Field Contains Text From Another Field

Aug 25, 2015

I'm new to SQL and I'm trying to write a statement to satisfy the following:

If [Field1] contains text from [Field2] then return [Field3] as [Field4].

I had two tables where there were no matching keys. I did a cross apply and am now trying to parse out the description to build the key.

View 8 Replies View Related

Searching For A Word In A Text File And Retuning It Using Script Taks In Ssis

May 10, 2007

does any one how to search for a word in a text file and return it back using the script task in ssis?



the file may contain data like this



POSITION SMSMSS20051230000

S ,,751600 ,,20051110,,20051230,20051230

S ,,751600 ,,20051110,,20051230,20051230

S ,,751600 ,,20051110,,20051230,20051230

S ,,751600 ,,20051110,,20051230,20051230

S ,,751600 ,,20051110,,20051230,20051230



what i am looking for is to be able to parse and get the date which is present in the first line "POSITION SMSMSS20051230000" as "20051230"

and then return that as a variable ..



Thanks for any help in advance



smathew







View 3 Replies View Related

Split Up Comma-delimited Field

Jun 7, 2002

I have a row in a SQL table that has 4 numerical values, separated by comma. I'd like to take this and make it 4 separate columns. Values are not always the same length, but are always delimited by commas.

Any ideas how I could do this in T-SQL?

View 9 Replies View Related

Can I Split A Field Based On A Character?

Nov 9, 2005

Here's a question for the SQL gurus out there:
I have a varchar(20) field DIAGNOSISCODE in a table that can either be null, or contain up to 3 comma-separated codes, each of which relates to a description in another table. For example, some sample rows might be
8060
8060,4450
8060,4123,3245
Now I need to structure a query to return these values from this single field as three fields CODE1, CODE2, CODE3, with NULL as appropriate for example
CODE1=8060, CODE2=4450, CODE3=NULL.
I have been using CASE along with CHARINDEX and PATINDEX but it it becoming extremely messy. Can anyone think of a "neater" way to return three fields from this one field?
Any help very greatly appreciated.
Thanks, Simon.

View 5 Replies View Related

Split Address Into Multiple Field

Aug 3, 2006

i want to write a code that can split the addresses into multiple fields. anyone can point me out where to start?



lets say i have "12 north plaza boulevard apt.16" and i want it to become:


address_number
12

suffixA
North

street_name
plaza blvd

suffixb
apt16


View 1 Replies View Related

Split One Field In Multiple New Rows

Nov 27, 2007

HiHo,
just a beginners question:

I have the following row with 2 fields:

Field 1: Task A
Field 2:´ 1;2;3;4

The number of semicolon divided elements in Field 2 is variabel.

I would like to create new rows like:

Row 1 Field 1: A Field 2: 1
Row 2 Field 1: A Field 2: 2
Row 3 Field 1: A Field 2: 3
Row 4 Field 1: A Field 2: 4


I think I should use a Foreach Loop.
But I don't exactly how to do it?

best regards
Chris

View 5 Replies View Related

Conditional Split On Field In Csv File

Jun 21, 2007

I know this should be simple but I can't figure it out. I am reading in a csv file to a conditional split task, all I want to do is split the file based on a field. Some values in field will have a suffix say ABCD while others wont. So my conditional split says Right(FieldA,4)=="ABCD" which then splits file in two directions or at least it's meant to. Problem is that it does not work. I think it has something to do with the field type in the csv file although I have tried using a Data Conversion task but to no avail all the field values with ABCD suffix are ignored by my conditional split and head off the same way as other values. Funny thing is is that if I manually add a value to the file with a suffix of ABCD and run task again then the conditional split works on the manually added row and all rows with suffix of ABCD. It's like it does not recognise previous values as string until one is added manually.

Thanks

View 8 Replies View Related

One For The SQL Gurus: Split A Delimited Field Into Rows

Aug 13, 2004

Hi.

I'm trying to write an SQL Query that will take a delimited field and return each item as a row.

Example

Take the AuthorizedRoles and TabID fields from the Tabs table

AuthorizedRoles TabID
0;11;__________1
0; 15 ;17;______6
-2;____________7

I would like to return a unique record for each Authorized Role

AuthorizedRole TabID
0____________1
11___________1
0____________6
15___________6
17___________6
-2___________7

Any ideas?

Cheers
Dave

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved