How to Show Corresponding Table Columns with Cursor

Jayakumars
Posted by Jayakumars under ASP.NET AJAX category on | Points: 40 | Views : 674
Hi

I have post the code .How to Show Corresponding Table Columns with Cursor

DECLARE @ename varchar(20)
DECLARE @lcl_name VARCHAR(100)
DECLARE cur_name CURSOR FOR
Select name FROM sys.objects where type='U'
OPEN cur_name
FETCH next from cur_name into @lcl_name
WHILE @@Fetch_status = 0
Begin
set @ename=(Select top(1) name FROM sys.objects where type='U')
Select TABLE_CATALOG,TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS where Table_name=@ename
print @lcl_name
Fetch next from cur_name into @lcl_name
End
Close cur_name
DEALLOCATE cur_name

Comments or Responses

Login to post response