Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting error in code

Status
Not open for further replies.

Saama5

Programmer
Jan 6, 2002
52
US
CREATE procedure xyz
@a int,
@b int out,
@c int out,
as
Declare @dbName nvarchar(35)
Declare @SqlStmt nvarchar(255)
Declare @RecNum int
SELECT DatabaseName,RecordNumber FROM Db1.dbo.Table1

DECLARE Cursor_1 CURSOR FOR


OPEN Cursor_1

FETCH NEXT FROM Cursor_1 into @dbName, @RecNum

WHILE @@FETCH_STATUS = 0
BEGIN
set @b = RecNum

select @c = fld1 from @dbName.dbo.Phone where fld2 = @a

if @c <> -1 break
FETCH NEXT FROM Cursor_1 into @dbName, @RecNum
ENd
CLOSE Cursor_1
DEALLOCATE Cursor_1
GO

How to write Select @c= fld1 .... statement. I am facing problem there because databaseName is dynamic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top