Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Sqlmm
Starting Member
3 Posts |
Posted - 2011-10-03 : 03:19:58
|
| Hello i have this SQl function, what i need to do is, make a split function. i have some tags, and i need to split my tags by using the split function, someone can help for a code to do that ?Create FUNCTION [dbo].[TEST] ( -- Add the parameters for the function herezs @TagList varchar(4000))RETURNS TABLE ASRETURN ( -- Add the SELECT statement with parameter references here SELECT StartTime, EndTime, Node, Tag, OPCItemID, EventText, Event, ValueFROM NRPVM_plantdatabase.dbo.vw_AlarmHistory where OPCItemID = @TagList) |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
vmvadivel
Yak Posting Veteran
69 Posts |
|
|
Sqlmm
Starting Member
3 Posts |
Posted - 2011-10-12 : 05:32:15
|
| thank for the response, but i think that i cant use the create function because i cant use the select statement, what about if i use the stored procedure ? any ideas how the split function will look like ? |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2011-10-12 : 05:42:40
|
It really depends how you want to go about it. The other way is to use a CLR function to split the string. This is faster in nearly all cases and you can then just join to the function. See http://www.sommarskog.se/arrays-in-sql-2005.html#CLR for more on this. If speed is not an issue, then you can use a function and simply join in your select statement to the function.so to split a strng with CLR you would create the CLR and create the assembly, then you could simply run sometyhing like the following:SELECT DISTINCT number AS OPCItemID FROM CLR_intlist_iter(@@TagList,',') |
 |
|
|
|
|
|
|
|