Query For Taking Each Word In A String, And Putting A Comma After It?
Aug 29, 2007
Hey all, i'm making the pages meta keywords on my site dynamic, and i was wondering is there is a string, for example "Dell 17" Monitor Brand New", that would split it into each word for the meta keywords. example "Dell, 17", Monitor, Brand, New" (and possibly to not put a comma on the last word?)
View 1 Replies
ADVERTISEMENT
Jan 22, 2006
Hi there
I have nearly 1000 table. I need all the table structure in word document. Is it possible to take table structure using Stored Procedure. If it is How to do that.
Thanx in advance
by
yasi
View 8 Replies
View Related
Feb 13, 2006
We have the following two tables :
Link ( GroupID int , MemberID int )
Member ( MemberID int , MemberName varchar(50), GroupID varchar(255) )
The Link table contains the records showing which Member is in which Group. One particular Member can be in
multiple Groups and also a particular Group may have multiple Members.
The Member table contains the Member's ID, Member's Name, and a Group ID field (that will contains comma-separated
Groups ID, showing in which Groups the particular Member is in).
We have the Link table ready, and the Member table' with first two fields is also ready. What we have to do now is to
fill the GroupID field of the Member table, from the Link Table.
For instance,
Read all the GroupID field from the Link table against a MemberID, make a comma-separated string of the GroupID,
then update the GroupID field of the corresponding Member in the Member table.
Please help me with a sql query or procedures that will do this job. I am using SQL SERVER 2000.
View 1 Replies
View Related
Jul 23, 2005
Hi allThis should be easy for one of you pros out there...I take a single string(one letter) from a textbox and want to query mydatabase for a name that starts with that letter.I know that the correct synthax when you know the letter is:WHERE FirstName LIKE 'O%'but when I have this:*****************Dim lastname As Stringlastname = txtlastname.TextDim strSQL As String = "SELECT * FROM [" & PubName & "] WHERE Last_Namelike ' txtlastname % ' "**********************************************It doesn't seem to work since my datagrid is empty afterwards. I alsotried:***************Dim strSQL As String = "SELECT * FROM [" & PubName & "] WHERE Last_Namelike '" & txtlastname & " % ' "****************without succes....It's probably just a synthax error on my part but I don'T know were..THanks guys!!JMT
View 3 Replies
View Related
Nov 21, 2006
I have following 2 queries which return different results.
declare @accountIdListTemp varchar(max)
SELECT COALESCE(@accountIdListTemp + ',','') + CONVERT(VARCHAR(10),acct_id)
FROM (SELECT Distinct acct_id
FROM SomeTable) Result
print @accountIdListTemp
The above query return the values without concatenating it.
declare @pot_commaSeperatedList varchar(max)
SELECT DISTINCT acct_id
into #accountIdListTemp
FROM SomeTable
SELECT @pot_commaSeperatedList = COALESCE(@pot_commaSeperatedList + ',','') + CONVERT(VARCHAR(100),acct_id)
FROM #accountIdListTemp
print @pot_commaSeperatedList
drop table #accountIdListTemp
This query returns result as concatenated string of comma separated values.
If i want to get similar result in a single query how can i get it?
View 4 Replies
View Related
Mar 10, 2015
I have a scenario where in I need to use a comma delimited string as input. And search the tables with each and every string in the comma delimited string.
Example:
DECLARE @StrInput NVARCHAR(2000) = '.NET,Java, Python'
SELECT * FROM TABLE WHERE titleName = '.NET' AND titleName='java' AND titleName = 'Python'
As shown in the example above I need to take the comma delimited string as input and search each individual string like in the select statement.
View 3 Replies
View Related
Aug 27, 2015
I have a parameter value as shown below and this is dynamic and can grow
Example : 101-NY, 102-CA, 165-GA
116-NY, 258-NJ, 254-PA, 245-DC, 298-AL
How do I get the values in the below format
NY,CA,GA --- each state to be followed with comma and the next state
NY,NJ,PA,DC,AL --- each state to be followed with comma and the next state
correct query that will fetch only state names and not the numbers.
View 8 Replies
View Related
Feb 6, 2007
Hallow, everyone:
I want to read third word from a string. For example, the string is,
ABCDE fghijk 031 LPN OPQ
I need 031. How to read it?
Any help will be appreciated.
Thanks
ZYT
View 12 Replies
View Related
Feb 25, 2008
Hi All,
Please help, it is urgent
I am having a colume as image datatype, in which candidates resume is stored in binary format.
I have to search for particular words for eg. "ASP.Net, 2 Years" into that column
I have converted that column as varchar and then searching above two words(after spliting them by comma) into that string using CHARINDEX
DECLARE @i int, @j int
SET @i = select MIN(ResumeId) from table_name
SET @j = select MAX(ResumeId) from table_name
WHILE (@i <= @j)
BEGIN
DECLARE @Resume varchar(max)
SET @Resume = CAST((select Resume from table_name where ResumeId=100) as varbinary(max))
--code to search the particular word from @Resume
END
It is working fine, but it is very slow, taking 2+ minutes to scan 15000 records
How can I make it faster or is there any other way to search?
Thanks in advance
View 7 Replies
View Related
Aug 29, 2013
Creating a stored procedure in extracting a word in a sentence.
Example:
String=The quick brown fox JuMp over the lazy dog.
I want to extract a random word on the string.
View 1 Replies
View Related
Oct 15, 2015
I have a values a column like this
Morning(07:00-16:30)
Morning(09:30-18:30)
Morning(11:00-20:00)
Afternoon(14:00-23:00)
Afternoon(16:00-01:00)
Morning(08:00-17:00)
Morning(10:00-19:00)
Morning(09:00-18:00)
So i just only need 07:00-16:30 this kind of part from above all these string in sql server.
View 4 Replies
View Related
Jun 30, 2015
Is there a function / way to extract a word from a particular position in the String.
I want to extract a word which is in the 16th position. All words are separated by spaces.
View 6 Replies
View Related
Jan 27, 2008
I have a checkbox list on datalist as one column. when user selects more than one checkbox and click on apply. i concatenate IDs of checkboxes as '1,2'3' for e.g. and sending that to Stroe Procedure as varchar datatype parametrer. In Procedure i wanna update status of all three selected and i am using statement "update tbl set status=1 where pageid in('1,2,3'). It is saying it cannot convert varchar to int.
How can i do this task?
Thanks in advance.
View 2 Replies
View Related
Mar 4, 2007
It's probably a most basic operation but I can't find how to enable this. Using SQL Server 2005
eg: how would I get this sort of step to work?
INSERT INTO company VALUES (10001,"Apps'r'Us");
where the schema is
(companyID int,
companyName varchar(50))
View 1 Replies
View Related
Mar 11, 2008
I have a string
@string = 'abc,def,ghi'
Now I have to display
abc
def
ghi
I have to separate a comma in that
Is there an function like split in sql
plz help me
Thanks in Advance
Suresh Kumar
View 5 Replies
View Related
Mar 11, 2008
Hi All,
I have one field with different values like
F1
A,B,C,
D,E
G,H,I,
My requirement is to remove the last comma from that string. I need the output should look like
F1
A,B,C
D,E
G,H,I
thanks,
Mears
View 9 Replies
View Related
Aug 16, 2013
I have a scenario which i must check if the value of the inputted word is exact (case sensitive) in a string. And print the word if correct. using a user defined function.
Example:The quick brown fox jump over the lazy dog.
If the user enter "jump" it must print "jump".
If the user enter "Jump" it must print "jump" which is the correct word.
View 4 Replies
View Related
Oct 18, 2005
I am trying to build a dynamic where statement for my sql stored prcoedure
if len(@Office) > 0 select @strWhereClause = N'cvEh.chOfficeId in (select id from dbo.csfParseDeLimitedText( ' + @vchOffice + ',' + ''',''' + '))' + ' and ' + @strWhereClause
In this case users can enter comma delimited string in their search criteria. So if they enter we1, we2, we3 then my sql statement should look like
select @strWhereClause = cvEh.chOfficeId in (select id from dbo.csfParseDeLimitedText('we1', 'we2', 'we3'),',')
My csfParseDeLimitedText function looks like this
Create FUNCTION [dbo].[csfParseDeLimitedText] (@p_text varchar(4000), @p_Delimeter char(1))RETURNS @results TABLE (id varchar(100))ASBEGIN declare @i1 varchar(200)declare @i2 varchar(200)declare @tempResults Table (id varchar(100))while len(@p_text) > 0 and charindex(@p_Delimeter, @p_text) <> 0beginselect @i1 = left(@p_text, charindex(@p_Delimeter, @p_text) - 1)insert @tempResults select @i1select @p_text = right(@p_text, len(@p_text) - charindex(@p_Delimeter,@p_text))endinsert @tempResults select @p_text
insert @resultsselect *from @tempResultsreturnEND
My problem is it does not put quotes around the comma delimited stringso I want to put 'we1' , 'we2'. These single quotes are not coming in the dynamic sql statement. How can I modify my query so that single quotes around each entry should show up.
Any help will be greatky appreciated.
Thanks
View 1 Replies
View Related
May 3, 2005
I have a table called evidence, which has the following Fields
| evidence_id | Description| Standards|
E001 blagh 1.1,1.2,1.3
Ok I am trying to search the comma-separated string in the standards field using the like clause so I can display the evidence_id.
SQL looks like
SELECT Evidence.Standards, *
FROM Evidence
WHERE (((Evidence.Standards) Like '%1.1%'));
However it will not search through the list and select for example if I change 1.1 to 1.2. The commas wont allow it.
It works if I just have one item in the list that is just 1.1. Can anyone help me to search a comma-separated string for a certain string?
Thanks
Asylum
View 3 Replies
View Related
Jun 3, 2008
Hello
I have a table with column Options where each field contains a comma delimited list of ID numbers.
I want to select any records where a certain ID number appears in that list.
So something like:
SELECT * FROM Table t1
WHERE MyID IN (SELECT Options FROM Table t2 WHERE t1.ID = t2.ID)
But that gives me the error:
Syntax error converting the varchar value '39,20' to a column of data type int.
I feel I'm close though! Could anyone point me in the right direction?
Many thanks
Square
View 3 Replies
View Related
Nov 22, 2013
I have a problem in a stored procedure trying to insert a comma delimited list into rows.The parameters for example would be somthing like....
@GarageID int = 20,
@Cars nVarChar(200) = Ford~Fiesta,BMW~320,Volvo~340,Jaguar~XJS
I need to split where the comma is for each new row, and separate each value from either side of the '~' like so....
GarageID Make Model
--------------------------------
20 Ford Fiesta
20 BMW 320
20 Volvo 340
20 Jaguar XJS
View 2 Replies
View Related
Mar 20, 2014
I want to bring a string parameter to where clause like this:
select .. from ...
Where Code IN (@Code)
When @Code is 'ABC' it works but when @code is 'ABC, XYZ' it won't work. I know for IN statement we should use IN ('ABC', 'XYZ') and I tried make @code = '''ABC'', ''XYZ''' still not working. I tried
Print '''ABC'', ''XYZ'''
I got 'ABC', 'XYZ' but why it does not work in @Code?
View 4 Replies
View Related
Dec 5, 2005
Hi there,I have created a sp and function that returns amongst other things acomma seperated string of values via a one to many relationship, thecode works perfectly but i am not sure how to test its performance.. Isthis an efficient way to achieve my solution.. If not any suggestionshow i can improve it.. What are the best ways to check query speed???MY SP:CREATE PROCEDURE sp_Jobs_GetJobsASBEGINSELECT j.Id, j.Inserted, Title, Reference, dbo.fn_GetJobLocations(j.id)AS location, salary, summary, logoFROM Jobs_Jobs j INNER JOIN Client c ON j.ClientID = c.idORDER BY j.Inserted DESCENDGO--------------------------------------------MY Function:CREATE FUNCTION fn_GetJobLocations (@JobID int)RETURNS varchar(5000) ASBEGINDECLARE @LocList varchar(5000)SELECT @LocList = COALESCE(@LocList + ', ','') + ll.location_nameFROM Jobs_Locations l inner join List_Locations ll onll.LocationID = l.LocationIDWHERE l.JobID = @JobIDRETURN @LocListENDAny help or guidance much appreciated...
View 2 Replies
View Related
Oct 1, 2007
I have a string like say: '3:4:5:4,2:4:1,4:1:2:5:2'. Now I need to split the substrings delimited by commas. So my final output shall be
3:4:5:4
2:4:1
4:1:2:5:2
I did write a piece of code to achieve the same, but I feel its not so efficient. Can anyone suggest me a better way, if any? My code is as follows:
Declare @person as varchar(255), @cnt smallint,@loc smallint,@prevloc smallint, @str varchar(255)
Select @prevloc=0,@loc=1,@cnt=1,@person = '3:4:5:4,2:4:1,4:1:2:5:2'
While @loc != 0
begin
set @prevloc=(case when @loc = 1 then 0 else @loc end) +1
set @loc = charindex(',',@person,@loc+1)
Set @str = substring(@person,@prevloc,(Case when @loc = 0 then len(@person) - @prevloc + 1 else @loc - @prevloc end))
print 'String = ' + @Str
set @cnt=@cnt+1
end
RESULT
------
String = 3:4:5:4
String = 2:4:1
String = 4:1:2:5:2
Note: My actual purpose is to also sub split it again with ':' delimiter too. So looking for an efficient code.
View 4 Replies
View Related
Sep 23, 1999
Hi,
In 6.5 you could run a query and then make a flat file with whatever format
you wanted.
I cannot find that option in 7.0. Can someone please tell me where it is????
Thanks,
Dianne Watson
View 5 Replies
View Related
Dec 8, 2006
I'm passing a comma delimited string to my SP, e.g.:"3,8,10,16,23,24"I need to retreive each number in this string and for every number found I need to execute some sode, say add "AND SportID="+numberfoundHow can I do that?
View 6 Replies
View Related
May 22, 2007
I have the following table:id name1 yes2 no3 what4 is5 this6 niceThe amount of rows can vary from 1 to 50. I only need the name column.What SQL statement do I have to execute to get the following:yes,no,what,is,this,nice, (trailing , is acceptable)Thanks!
View 1 Replies
View Related
May 27, 2005
Hello,
I was wondering if it's possible to pass in a comma separated string
"12,14,16,18" and use it in a stored procedure with "IN" like this:
@SubRegions varchar(255) <-- my comma separated string
SELECT *
FROM myTable
WHERE tbl_myTable.SubRegionID IN (@SubRegions)
It tells me it has trouble converting "'12,14,16,18'" to an INT. :(
View 2 Replies
View Related
Dec 1, 1999
I have a string of comma delimited values such as the following:
1,2,3,4,5
I have a table with ONE column only. How can I do an insert statement which will insert each of these values?
If I type the following:
"INSERT INTO tabletest SELECT 1,2,3,4,5"
I get this error:
"Insert error: column name or number of supplied values does not match table definition. "
This makes sense because I do not have 5 columns I only have 1. But how can I get around this?
Any help is most appreciated! Thanks in advance...mary
View 1 Replies
View Related
Jul 20, 2005
Hi,I would like to parse out each value that is seperatedby a comma in a field and use that value to join to another table.What would be the easiest way to do so without having towrite a function or routine ?EX.Table AAACOL1 COL21 11, 124, 1562 11, 505, 600, 700, ...Table BBBCOL1 COL211 Desc11124 Desc124156 Desc 156
View 2 Replies
View Related
Oct 8, 2008
I have a parameter called Id in my SP which will be of nvarchar data type and i'm going to get the multiple ids at a time seperated by commas in that parameter from the application. Now my requirement is to update a table with these comma seperated ids in seperate rows.
For example, if i have 2 parameters called Id1 and Id2. Id1 will contain only one value and will be of int data type and Id2 will be of nvarchar data type as i can get multiple ids delimited by a comma from the application.
Suppose Id1 = 1 and Id2 = '1,2,3,4'. Then I have to update id2 in the tables seperately like wherever Id1 is '1' i need to update Id2 column for 4 rows with the value 1, 2, 3, 4 respectively in different rows.
how can i do this in T-SQL? How can i split the data of parameter Id2 in 4 different rows?
View 24 Replies
View Related
Sep 7, 2006
I have a field called CustomerName Varchar 100 and I wish to write a function that can do the following in a script component task
create a function called CleanString (ByVal CustomerName as String) As String
CleanString Returns the last word of a Customer name if the CustomerName field contains more than one word or if the CustomerName field does not contain Corp or Ltd
ie parse 'Mr John Tools' and the function returns 'Tools'
ie parse 'TechnicalBooks' and the function returns 'TechnicalBooks'
ie parse 'Microsoft Corp' return 'Microsoft Corp'
ie parse 'Digidesign Ltd' return 'Digidesign Ltd'
Any idea of a regular expression or existing piece of existing code I can have
thanks in advance
dave
View 3 Replies
View Related
Aug 6, 2015
I am required to find or check that a specific word exists in string or not.
Suppose I have to find the word 'st' than I need the result true if and only if the following occurrences are there.
1. 'St is valid;' -> true
2. 'DOB is valid;ST is invalid;' -> true
3. 'DOB is valid; ST is invalid;' -> true
4. 'DOB is valid;invalid ST;' -> true
5. 'DOB is valid; invalid ST;' -> true
6. 'DOB is valid; invalid STate;' -> false
Means the exact ST should be search. It is not free text search.
T-SQL is needed to be used in select statement with case using PATINDEX, RegEx or any suitable t-sql command.
View 10 Replies
View Related