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)
 Problem creating a table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-30 : 08:48:05
Rodney writes "I am trying to build a lookup table in a Stored procedure... and i get an error saying something about sp_dboption... here is the stored proc.

Version - SqlServer7 : WinNT 4.0 : SP (latest)

Alter Procedure dbo.sp_createlookup
As
Create Table CityLookup (
ID int identity,
City nvarchar(50),
State nvarchar(2));

DECLARE @State_Table nvarchar(2)
Declare @sql varchar(100)

DECLARE c1 CURSOR FOR
SELECT state
FROM state_list

OPEN c1

FETCH NEXT FROM c1
INTO @State_Table

WHILE @@FETCH_STATUS = 0
BEGIN

set @sql = 'select distinct(City), state into CityLookup from [' + @state_Table + ']'
Exec(@sql)

FETCH NEXT FROM c1
INTO @State_Table
END

CLOSE c1
DEALLOCATE c1

am i doing something wrong here? Can what i am trying to accomplish be done?

thanks for any help.

Rod"
   

- Advertisement -