我有一张下表(#Temp):
RowNo Item
1 A
2 B
我的要求是Item
等于B
采取行动。
declare @count int = 1
WHILE(@count < (select count(*) from #Temp))
Begin
// Here I have to access my column name(Item) , so that I can check its value to B
set @count = @count + 1
End
请建议
答案 0 :(得分:-1)
您可以使用DESCRIBE:
DESCRIBE my_table;
或者在较新的版本中,您可以使用INFORMATION_SCHEMA:
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'my_database' AND TABLE_NAME = 'my_table';
或者您可以使用SHOW COLUMNS:
SHOW COLUMNS FROM my_table;