Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Stored Proc - insert into multiple tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-09-26 : 10:12:02
Forti writes "I am trying to write a stored proc that will take rows from one table and insert those rows into several tables based on the first initial of the LastName field. For example the Base table contains Last Names A-Z (unordered). I would like to cycle through the Base Table and select one record at a time and insert it into the appropriate table, ie. tblA, tblB,..., tblWXYZ, etc. I know that in order to Select the appropriate table I need something like:

SELECT name FROM sysobjects where name like '%tbl%' + @initial + '%' and type = 'U'

=======================================================
@initial = char(1)



Any tips would be greatly appreciated."
   

- Advertisement -