SQL definition methods and cross apply usage

New table tb1

id name
1 A
2 B
3 C

 

Definition method

CREATE FUNCTION testfun
(

  - Input parameters
  the @name VARCHAR (50)
)
the RETURNS TABLE
the AS
the RETURN
(

  - Output (column name must be specified)
  the SELECT the @name + 'Tess' Response
)
the GO

 

SELECT * FROM dbo.tb1 t1 CROSS APPLY testfun(t1.name)

Export

id name response
1 A Atess
2 B Btess
3 C Ctess

 

 

Cross Apply query can be used before a value of the field in the association table associated with the sub-table

If the query result sets need to use a table-valued function of the value of a field is processed, please use the CROSS APPLY

 

Guess you like

Origin www.cnblogs.com/licx/p/11161769.html