Hi,
We have a developer who exceutes the following fine as an SQl statement in query tools.
###############################################
BEGIN
SET NOCOUNT ON;
DECLARE @EventIDRecordType VARCHAR(26);
DECLARE @Name VARCHAR(256);
DECLARE @Members VARCHAR(3000);
DECLARE @Current_EventIDRecordType VARCHAR(26);
DECLARE @tmptbl TABLE (EventID VARCHAR(18), RecordType VARCHAR(8), Members VARCHAR(3000));
DECLARE mbr_cursor cursor FOR
SELECT eventid+recordtype, Name
FROM dbo.PruforceEventAttendee
ORDER BY 1, 2;
OPEN mbr_cursor;
FETCH NEXT FROM mbr_cursor INTO @EventIDRecordType, @Name;
SET @Current_EventIDRecordType = ' ' ;
SET @Members = '' ;
WHILE @@FETCH_STATUS = 0
BEGIN
IF @EventIDRecordType != @Current_EventIDRecordType
BEGIN
IF @Current_EventIDRecordType != ' '
INSERT INTO @tmptbl
VALUES(substring(@Current_EventIDRecordType,1,18), substring(@Current_EventIDRecordType,19,8), @Members);
SET @Current_EventIDRecordType = @EventIDRecordType;
SET @Members = RTRIM(@Name);
END
ELSE
SET @Members = @Members + ', ' + RTRIM(@Name);
FETCH NEXT FROM mbr_cursor INTO @EventIDRecordType, @Name;
END
INSERT INTO @tmptbl
VALUES(substring(@Current_EventIDRecordType,1,18), substring(@Current_EventIDRecordType,19,8), @Members);
CLOSE mbr_cursor;
DEALLOCATE mbr_cursor;
SELECT * FROM @tmptbl;
END
###############################################
When he pastes this in the user defined SQl field in the ODBC enterprise edition he receives the error:
main_program: [IBM (DataDirect OEM) ][ODBC SQL Server Driver][SQL Server]Line 2: Incorrect syntax near 'OFF'.
Followed by:
xfmCombineAttendees: Error when checking operator: Could not find input field "EventID".
We ahve never tried this type of SQl before and wondering if this should work.
Thanks - - John
SQL server sql question
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 306
- Joined: Wed Jun 21, 2006 11:41 am
SQL server sql question
Last edited by JPalatianos on Wed Feb 02, 2011 12:29 pm, edited 1 time in total.
-
- Premium Member
- Posts: 306
- Joined: Wed Jun 21, 2006 11:41 am
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Premium Member
- Posts: 306
- Joined: Wed Jun 21, 2006 11:41 am