When we do SELECT * FROM table we get all records in a table, If I want to get only a row but do not know the number of columns
like
id att1 att2 att3.... attx
-------------------------------
1 45 5 3 7
How do I do a select statement that returns all columns?
I know I must use
from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'myTable'
and a Where clause: WHERE id = 1
but again I do not know the number of columns…
Just add a where clause to the end of the @sql statement to limit your selection to the rows you want: