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.
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.
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.
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 ?
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...
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
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
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!
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?
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
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
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.
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
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 ?
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?
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?
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!
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?
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.
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.
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.