title: sql server 2000 stored procedure
body: <p>I have created a store procedure for updating the patient name in multiple tables. When I  execute it, shows the error like</p>
  
  <blockquote>
    <p>Server: Msg 170, Level 15, State 1,<br>
    Line 1 Line 1: Incorrect syntax near
    '='.</p>
  </blockquote>
  
  <p>This is my code. How to recover it? Please help me</p>
  
  <pre><code>create procedure uppatname @pid varchar(150),@pname varchar(150)
  as begin
    declare @i as integer
    declare @i1 as integer
    declare @ttnm  as varchar(100)
    declare @tblnam as varchar(100)
  
    drop table tbname
    SELECT IDENTITY(int, 1,1) AS RowNumber, table_name  
      INTO tbname  
      FROM information_schema.columns 
      WHERE column_name = 'pid' 
        AND table_catalog = 'hospital' 
        AND table_name NOT LIKE 'T%'
  
    SET @i = (select count(*) from information_schema.columns 
              where column_name='pid' and table_catalog='hospital' 
                and table_name not like 'T%')
  
    SET @i1 = 1
  
    WHILE @i1 &lt;= @i
    BEGIN
       SET @tblnam = (select table_name  from tbname where rownumber = @i1)
       SET @ttnm = ('select  * from ' + @tblnam + 'where pid = ' + @pid)
       EXEC (@ttnm)
       SET @i1 = @i1 + 1
    END
  END
  </code></pre>