mgmhicks
asked on
Problem with SQL Script - Cannot call methods on varchar
I have the following script and keep receiving the error,"Cannot call methods on varchar". Could someone tell me whats wrong witht he script. It points to line 26
declare @cursor cursor
declare @mUserID char(25) = 'shicks'
declare @Propertyid char(2)
declare @BldgID char(30)
declare @UnitID char(30)
declare @ResiID char(10)
set @cursor = CURSOR FOR SELECT distinct PropertyId,BldgId,UnitId,R esiId
FROM TransactionHeader
WHERE (TransType = '3') AND (GLPeriod = '201204') AND (ACHFlag = 'N') AND (ImportedFrom IS NULL) AND (SourceCode <> 'AO') and PropertyId IN (select code from locationList where LocationID = 8)
ORDER BY PropertyId,BldgId,UnitId,R esiId
open @cursor;
FETCH NEXT FROM @cursor INTO @propertyid,@bldgid,@uniti d,@resiid
WHILE @@FETCH_STATUS = 0
BEGIN
declare @cursor2 cursor
declare @ResiFirstName char(50)
declare @ResiLastName char(50)
declare @ResiStatus char(1)
declare @Phone1 char(25)
declare @Email char (25)
set @cursor2 = CURSOR FOR SELECT a.ResiFirstName,a.ResiLast Name,a.Res iStatus.b. phone1No,b .email from lease a
inner join Addressbook b on a.PrimaryAddrID = b.addrID
where (a.propertyid=@propertyid and a.bldgid=@bldgid and a.unitid=@unitid and a.resiid=@resiid) and (a.ResiStatus = 'c' or a.ResiStatus='n')
open @cursor2
fetch next from @cursor2 into @resiFirstName,@resiLastNa me,@resist atus,@Phon e1,@Email
while @@FETCH_STATUS= 0
begin
insert into dbo.mgm_TempTable1 Values(@mUserID,@Propertyi d,@BldgID, @UnitID,@R esiID,@res iFirstName ,@resilast name,@resi Status,@Ph one1,@emai l)
fetch next from @cursor2 into @resiFirstName,@resiLastNa me,@resist atus,@Phon e1,@Email
end
deallocate @cursor2
FETCH NEXT FROM @Cursor INTO @propertyid,@bldgid,@uniti d,@resiid
END
DEALLOCATE @Cursor
declare @cursor cursor
declare @mUserID char(25) = 'shicks'
declare @Propertyid char(2)
declare @BldgID char(30)
declare @UnitID char(30)
declare @ResiID char(10)
set @cursor = CURSOR FOR SELECT distinct PropertyId,BldgId,UnitId,R
FROM TransactionHeader
WHERE (TransType = '3') AND (GLPeriod = '201204') AND (ACHFlag = 'N') AND (ImportedFrom IS NULL) AND (SourceCode <> 'AO') and PropertyId IN (select code from locationList where LocationID = 8)
ORDER BY PropertyId,BldgId,UnitId,R
open @cursor;
FETCH NEXT FROM @cursor INTO @propertyid,@bldgid,@uniti
WHILE @@FETCH_STATUS = 0
BEGIN
declare @cursor2 cursor
declare @ResiFirstName char(50)
declare @ResiLastName char(50)
declare @ResiStatus char(1)
declare @Phone1 char(25)
declare @Email char (25)
set @cursor2 = CURSOR FOR SELECT a.ResiFirstName,a.ResiLast
inner join Addressbook b on a.PrimaryAddrID = b.addrID
where (a.propertyid=@propertyid and a.bldgid=@bldgid and a.unitid=@unitid and a.resiid=@resiid) and (a.ResiStatus = 'c' or a.ResiStatus='n')
open @cursor2
fetch next from @cursor2 into @resiFirstName,@resiLastNa
while @@FETCH_STATUS= 0
begin
insert into dbo.mgm_TempTable1 Values(@mUserID,@Propertyi
fetch next from @cursor2 into @resiFirstName,@resiLastNa
end
deallocate @cursor2
FETCH NEXT FROM @Cursor INTO @propertyid,@bldgid,@uniti
END
DEALLOCATE @Cursor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window