Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SET NOCOUNT ON;
- DECLARE @airport_set_id int, @airport_set_name nvarchar(50),
- @airport_code nvarchar(50), @country_code nvarchar(50), @country_airport_code nvarchar(50);
- PRINT '{'
- --SELECT @message = '{'
- DECLARE airport_set_cursor CURSOR FOR
- SELECT SegmentationAirportSetID, SegmentationAirportSetName
- FROM [ConfigurationMaster].[dbo].[SegmentationAirportSet]
- ORDER BY SegmentationAirportSetName;
- OPEN airport_set_cursor
- FETCH NEXT FROM airport_set_cursor
- INTO @airport_set_id, @airport_set_name
- WHILE @@FETCH_STATUS = 0
- BEGIN
- PRINT ' "' +
- @airport_set_name + '":['
- --SELECT @message = @message + ' "' +
- -- @airport_set_name + '":['
- -- Declare an inner cursor based
- -- on airport_set_id from the outer cursor.
- DECLARE airport_set_airport_cursor CURSOR FOR
- SELECT ASA.AirportCode
- FROM [ConfigurationMaster].[dbo].[SegmentationAirportSetAirport] ASA
- WHERE ASA.SegmentationAirportSetId = @airport_set_id
- OPEN airport_set_airport_cursor
- FETCH NEXT FROM airport_set_airport_cursor INTO @airport_code
- DECLARE @message varchar(max) = '', @message2 varchar(max) = '', @message3 varchar(max) = '', @message4 varchar(max)
- IF @@FETCH_STATUS <> 0
- PRINT ' <<None>>'
- WHILE @@FETCH_STATUS = 0
- BEGIN
- --PRINT @airport_set_name + ': ' + @airport_code
- --print LEN(@message)
- SELECT @message = @message + '"' + @airport_code + '",'
- if(LEN(@message) > 7990)
- BEGIN
- PRINT @message
- SET @message = ''
- END
- FETCH NEXT FROM airport_set_airport_cursor INTO @airport_code
- END
- CLOSE airport_set_airport_cursor
- DEALLOCATE airport_set_airport_cursor
- --Remove the last comma(',')
- SELECT @message = LEFT(@message, LEN(@message)-1)
- PRINT @message
- PRINT '],'
- -- Get the next airportset.
- FETCH NEXT FROM airport_set_cursor
- INTO @airport_set_id, @airport_set_name
- END
- --SELECT @message = LEFT(@message, LEN(@message)-1)
- CLOSE airport_set_cursor;
- DEALLOCATE airport_set_cursor;
- PRINT '}'
- --SELECT @message = @message + '}'
- --PRINT @message
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement