I have a table with a column called members and in it the rows are like ID Members ---------- ----------- 1 1\2\3 2 2\3\4 3 2\3 4 1\5 I have a reference table where 1 = father, 2= mother, 3=sister, 4=brother, 5=grapnparents. Is there any way I can query the memebers table like this ID ...
You need to use splitting function, such as fnSplit and then you would concatenate results into one string back. See the first part of the task CODE declare @Members table (MemberID int identity(1,1), member varchar(100)) insert into @Members values ('1\2\3'), ('2\3\4'), ('2'),('1\5') declare @Delimiter varchar(10) = '\' select X.*, Ref.Description from (select M.*, Value from @...
Here is fnSplit function I use CODE -- Test query ALTER FUNCTION [dbo].[fnSplit] (@list VARCHAR(8000), @delim CHAR(1) = ',' ) RETURNS TABLE AS RETURN WITH csvtbl(START, stop) AS ( SELECT START = 1, stop = CHARINDEX(@delim COLLATE Slovenian_BIN2, @list + @delim) UNION ALL SELECT START = stop + 1, stop = CHARINDEX(@delim COLLATE Slovenian_BIN2,...
mankish, What version of SQL Server are you using? It'll make a difference in the code for the answer on this. --Jeff Moden -------------------------------------------------- ----------------------------- " RBAR " is pronounced "ree-bar" and is a "Modenism" for " R ow B y A gonizing R ow"
What you really need to do is change your exceedingly poor design. You should NEVER store mulitple peices if information in one field like that. You need a related table where you can store the data properly and then it is trivial to query. "NOTHING is more important in a database than integrity." ESquared
I have a table with a column called members and in it the rows are like ID Members ---------- ----------- 1 1\2\3 2 2\3\4 3 2\3 4 1\5 I have a reference table where 1 = father, 2= mother, 3=sister, 4=brother, 5=grapnparents. Is there any way I can query the memebers table like this ID Members ---------- ------------------ 1 father,mother,sister 2 mother,sister, brother 3 mother,sister 4 father,grandparents. What I want to do is just replace...
mankish, What version of SQL Server are you using? It'll make a difference in the code for the answer on this. --Jeff Moden ------------------------------------------------------------------------------- " RBAR " is pronounced "ree-bar" and is a "Modenism" for " R ow B y A gonizing R ow"
What you really need to do is change your exceedingly poor design. You should NEVER store mulitple peices if information in one field like that. You need a related table where you can store the data properly and then it is trivial to query. "NOTHING is more important in a database than integrity." ESquared
This doesn't feel right, am I missing something? :... This doesn't feel right, am I missing something? : <%# string.Format( "{0:yyyy-MM-dd}", DateTime.Parse( ( string )XPath( "pubDate" ) ) ) %>
7:46 AM Nov 4th from TweetDeck
Thread profile page for "Parse String" on http://www.tek-tips.com.
This report page is a snippet summary view from a single thread "Parse String", located on the Message Board at http://www.tek-tips.com.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity