Click to See Complete Forum and Search --> : Skip one column in the table :: SQL


jayender.vs
September 22nd, 2005, 02:52 AM
Hi,
I need to skip one column from my table ...
say i got
select * from table1
Table1 contains 100 columns.
i need 99 column and i dont need the remaiing 1 column where the image is stored.
is it possible to skip that 1 column ?
condition:
1) I dont want to enter all the 99 column name in the query.

is there any solution ?

wiating ....!!!!

srinika
September 23rd, 2005, 08:50 AM
I'm not sure whether u need a 'query' or just any method.

Anyway see whether my solution fits you

DECLARE @s VARCHAR(8000)
SELECT @s=''
SELECT @s=@s + Column_name + ','
from INFORMATION_SCHEMA.Columns
where table_name = 'MyTable' and Column_name != 'Unwanted_Column'
set @s = left(@s, Datalength(@s)-1)
set @s = 'Select ' + @s + ' from MyTable'
execute ( @s)

Srinika