Declare Varibales In SQL 2000
-
Hi friends I make a function in sql 2000. I pass One parameter to that function and i return a table from that function i have 3 different tables. 1 is master table. e.g i have table of doctor i.e master and another 2 are 1 is specialization and another is status in specialization there are specialities of doctror like GP, Physician etc and in status the status of doctor is Important and very Important etc I want result like this Important very Important GP 4 5 Phy 3 2 first row indicate 4 Gp doctors are important and 5 are very important i make a function to return this result but i dont know how many Specialities in table and how many status so i want to alter temperory table in the function create function abc(@docid) returns table @tab (no varchar(10)) as begin declare @spec varchar(20) declare @vis varchar(20) declare @no int declare @ctr int select @ctr = count(visittypeid) from doc_visitytype where visitytypeid <> 0 while (@ctr >= 0) begin select @vis = visittype from doc_visittype where visittypeid = @ctr ALTER TABLE @tab ADD @vis varchar(10) end return end this code add the columns in the temporary table but @vis is local veriable how can i assign a veriable that it should take value of @vis as a coloumn name Thank You