Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
what are the stored Procedure and User-definde function and difference between them in sql server 2005
Posted
Updated 18-Jun-12 19:09pm
v2
Comments
member60 19-Jun-12 0:30am    
you are talking about Stored procedures and functions in sql server both are different , right ?
Agustee 19-Jun-12 0:56am    
What you asking about store procedure or functions?

for creating stored function first click on database -> programmability->function->table-value functions or sclar-valued functions then right click and select new scalr-value or table-value function as you want.
example:->
SQL
--select * from DatabaseName.dbo.split('CON,CON1,CON2',',')
Create FUNCTION [dbo].[Split](@String varchar(max), @Delimiter char(1))
returns @temptable TABLE (items varchar(max))
as
begin
    declare @idx int
    declare @slice varchar(max)

    select @idx = 1
        if len(@String)<1 or @String is null  return

    while @idx!= 0
    begin
        set @idx = charindex(@Delimiter,@String)
        if @idx!=0
            set @slice = left(@String,@idx - 1)
        else
            set @slice = @String

        if(len(@slice)>0)
            insert into @temptable(Items) values(@slice)

        set @String = right(@String,len(@String) - @idx)
        if len(@String) = 0 break
    end
return
end

this function work like split functon of string.
for more look at Differences between Stored Procedures and Functions[^]
 
Share this answer
 
v3
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900