Hi,

On executing CROSS APPLY Clause using UDF:

create function Reg(@pc int,@pp varchar(15))
Returns Table
As
Return select cr from crt where piod=@pc and cr=@pp
Go

select distinct a.cr from cdet AS a CROSS APPLY
Reg(a.cr,a.piod)  AS a
where a.piod='208'**

Am getting this following errors: Incorrect Syntax near '-'. Thanks.

There are so many things wrong with this post I hardly know where to start.
1. No table structures, relationships or datatypes for tables 'crt' or 'cdet' to help us figure out whether your function call is correct.
2. Your select statement starting on line 7 uses the correlation name 'a' for both the table and the returned table from the function.
3. On line 9 you have two trailing asterisks that cause a syntax error
4. You seem to be confusing which column goes to which parameter inside the function; i.e. when you call your function, you choose a.cr as the first parameter (int datatype), but inside the function you compare the column cr to the variable @pp, which is a varchar.
5. No explanation about what you expect your result set to be, no sample data, no indication of where the hyphen comes into play.

Look, I like a challenge as much as the next guy, but this is ridiculous. Clean it up, explain it better and MAYBE someone can help you figure it all out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.