SQL Server Scalar variable in Inline table valued function -


I have a multi-statement table value which I would like to change in a / customization Inline table value for the purposes of value (I really do not know that this would be an optimization, but I want to try anyway). My problem is that I have a scalar variable which I do not know how to write my with statement.

Code example: Start as

] [function] () Returns @ Return table (ID INT, Value NVARCHAR (500) Convertible BIGINT INSTER @tmp_table [... insert code ...] SET @variable = (Select @tmp_table from MAX (ID)) @ turn_table Select ID, value @ Tmp_table WHERE id = @Rariable Return

This code is an example, the actual function is more complex, but the problem is the same

I Easily with a single with like this Than:

  Construction work [dbo]. [Function] Returns as returns (as returns (as tmp_table ([selection code ....]) SELECT id, value from tmp_table WHERE id = [variable]); Geo  

My problem is in [variable] which I do not know how to put in the query In addition, variable is used more than once in my function so I do not want to change it with the query.

I also tried this approach:

  Construction work [DBO] [Function] Return (Return as return form) Return to form (as tmp_table (SELECT [... select code ...]), variable = (SELECT MAX (id) value from tmp_table) SELECT id, value tmp_table WHERE id = (SELECT TOP 1 value from FROM));     

just try

  with tmp_table as (SELECT [... select code ...]) SELECT id, value to tmp_table WHERE id = ( 

I actually change it by

  SELECT TOP 1 * FROm [whatever] ORDER ID IDE  

select MAX (id) code>


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -