If I have this table TableABC
and it has some fields/columns, rather say it has many fields/columns col1, col2, col3.....
say upto 10
or 20
, the count doesn't matter right now.
The point is, I wanna know, if we ask a user for input, say @input varchar(max)
or something like this, what I wanna know is that..
How can I select a row, if this input occurs in any column in that row, I mean the row would be selected if col1=@input
also if col2=@input
and so on..
Now as I said the count of column doesn't matter, what matters is we don't know ahead of time the columns so that we may do something like
where
col1 = @input
or
col2 = @input
we can't do that. I got as far as getting the names of column from table by say
SELECT [name] FROM sys.Columns WHERE [Object_id]=Object_id(N'TableABC')
This would give us names of col in the required table, now I don't know what can we do with them, or is this even useful in the scenario I am describing? So, what's the solution?
Lastly, in case someone might ask, where am I gonna use it, or what's my requirement or something, let me clear its not for (at least as of now!) practical implementation, I just wanna know if its possible, and if so, how? I hope I made myself clear.