|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using SubString With a Select StatementI've been battling with an issue for some time now and can't come up with a solution. I have a table (FSStacks) with just 1 column (FSStack VarChar(25)). The values of FSStack could be e.g. "ABCD", "EFGH:IJKL" I'm updating another table (PPOFSIDS) with the contents of FSStack but need to break down values that are separated by a colon into 2 values. Eack value for the other table can only be 4 chars. Table FSStacks has 1 column (FSStack) Varchar (25) where multiple 4 character codes can be stored in one column separated by a colon(:). Table PPOFSIDS has 2 columns: 1) An Identity column (PPOFSID), 2) FSRVAL Char(4) Here's my insert statement but I don't know how to add the SubString so I can break out "EFGH:IJKL" into 2 values - "EFGH" and "IJKL" so they both be inserted into table PPOFSIDS. INSERT into PPOFSIDS SELECT FS.FeeS as FSRVAL FROM FSStacks as FSS LEFT OUTER JOIN PPOFSIDS as IDS on IDS.FSRVAL = FSS.FSStack ?? WHERE IDS.PPOFSID IS NULL ORDER BY IDS.FSStack Any suggrstions will be greatly appreciated! And here I go again with my favourite (by Dejan Sarka):
http://solidqualitylearning.com/blogs/dejan/archive/2004/10/22/200.aspx ML --- http://milambda.blogspot.com/ Thanks so much! It's exactly what I was looking for :-)
Show quote "ML" wrote: > And here I go again with my favourite (by Dejan Sarka): > http://solidqualitylearning.com/blogs/dejan/archive/2004/10/22/200.aspx > > > ML > > --- > http://milambda.blogspot.com/ Ok. :-)
Show quote "ML" wrote: > Don't forget to thank Dejan in his Blog. :) > > > ML > > --- > http://milambda.blogspot.com/ Hmmm.
I thought I had what I was looking for but the example uses a string containing elements separated by a comma that is passed when calling the UDF. My situation is slightly different in that I have a "Select ColumnName From" etc. that would need to be passed to the UDF. I dont know how to pass the information to the UDF when what I'm passing is not a string but a set of rows from a table. TIA, Rita Show quote "RitaG" wrote: > Ok. :-) > > "ML" wrote: > > > Don't forget to thank Dejan in his Blog. :) > > > > > > ML > > > > --- > > http://milambda.blogspot.com/ I'm thinking about using a cursor to read from my table. Each line from the
table would then be passed into the UDF and that would work for me. I was told that cursors were slow but since my table will only have a couple of hundred rows this will not be a problem. Show quote "RitaG" wrote: > Hmmm. > I thought I had what I was looking for but the example uses a string > containing elements separated by a comma that is passed when calling the UDF. > My situation is slightly different in that I have a "Select ColumnName From" > etc. that would need to be passed to the UDF. > I dont know how to pass the information to the UDF when what I'm passing is > not a string but a set of rows from a table. > > TIA, > Rita > > "RitaG" wrote: > > > Ok. :-) > > > > "ML" wrote: > > > > > Don't forget to thank Dejan in his Blog. :) > > > > > > > > > ML > > > > > > --- > > > http://milambda.blogspot.com/ |
|||||||||||||||||||||||