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
@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