Archive

Posts Tagged ‘UDF’

Using Table-Valued UDF’s instead of view

CREATE FUNCTION [owner_name.]function_name
( [ { @parameter_name
data_type [ = default ]
} [ ,…n ] ] )RETURNS TABLE [ WITH [ ,…n
] ]
[ AS ] RETURN [ ( ] select_statement [ ) ]

CREATE FUNCTION
dbo.itvf_authors
( @au_lname VARCHAR(40)
)
RETURNS TABLE

RETURN SELECT au_id, au_fname, au_lname,
city, stateFROM
authorsWHERE au_lname =
@au_lnamego

SELECT * FROM
dbo.itvf_authors ( @author )

Hummm.. Looks nice..

Categories: Microsoft SQL Server Tags:
%d bloggers like this: