Click here to Skip to main content
15,890,347 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
What is a dynamic field in SQL, and when does it become in a dynamic table? Could someone help me?

I was looking for information but I can't find examples and I was practicing but I want to learn how to do a little more.

Thanks.
Posted
Updated 8-Apr-11 18:55pm
v2
Comments
Sandeep Mewara 9-Apr-11 0:58am    
I am not very sure of what you mean by 'Dynmaic field and tables'

Can you share a scenario that you are talking of or whatever you know of? Is it a Temporary table? Local variables?

The question can be related to many different things. Few examples:
- table types, used for example to dynamically transfer data to/from stored procedure
- computed columns in a table
- calculated fields in an SQL statement
- dynamic SQL statements
- inline views etc

If you explain a bit more what information you're looking for then the answers can be more accurate.
 
Share this answer
 
Comments
Juan-ITSM 9-Apr-11 17:46pm    
Thanks for the answer and yes, i´ve been writing stored procedures, but i need to calculate fields in a senteces and im a litle confuse about it for example i have something like this... and after studied, i understood, but i still cant find examples online about this...
im trying to see when a dinamic sql statement becames in a table etc...
thanks for your help.

select IdCliente, Nombre, TotalDeCompras from
(
select IdCliente, Nombre, Paterno,
(
select COUNT(IdCliente)
from Ventas
where Ventas.IdCliente=c.IdCliente
)
as TotalDeCompras from Cliente c
) as NoSe where TotalDeCompras = 0
Wendelius 10-Apr-11 1:11am    
Ok, the concept is named inline view or derived table. The syntax can be found here: http://msdn.microsoft.com/en-us/library/ms177634.aspx. With this you can rewrite your sql in a different format for example to avoid complex joins.

The idea is that the innermost select is executed first, then joined to the outer and so on. This is not what actually happens but it's a design time logic. You can think of the result of a derived table just like it was a normal table created by your inner query.
Try this Link

Click [^]
 
Share this answer
 
Comments
Juan-ITSM 9-Apr-11 17:46pm    
Thanks for the answer and yes, i´ve been writing stored procedures, but i need to calculate fields in a senteces and im a litle confuse about it for example i have something like this... and after studied, i understood, but i still cant find examples online about this...
im trying to see when a dinamic sql statement becames in a table etc...
thanks for your help.

select IdCliente, Nombre, TotalDeCompras from
(
select IdCliente, Nombre, Paterno,
(
select COUNT(IdCliente)
from Ventas
where Ventas.IdCliente=c.IdCliente
)
as TotalDeCompras from Cliente c
) as NoSe where TotalDeCompras = 0

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