Created
March 15, 2016 13:26
-
-
Save zv0r/111b362254d69f99a625 to your computer and use it in GitHub Desktop.
Подготовка справочника фондов для сайта
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
CAST('INSERT INTO fund (isn_fund, isn_archive, isn_doc_type, isn_period, fund_num_2, fund_name_short, fund_name_full, annotate, movement_note, fund_history, doc_start_year, doc_end_year, doc_receipt_year, last_checked_year) VALUES (' + CONVERT(nvarchar(max), (aff.ISN_FUND - 10000000000)) + ', ' + CONVERT(nvarchar(max), (aff.ISN_ARCHIVE - 10000000000)) + ', ' + CONVERT(nvarchar(max), ISNULL(aff.ISN_DOC_TYPE, 1)) + ', ' + CONVERT(nvarchar(max), CAST (CASE WHEN ISNULL(aff.FUND_NUM_1, '') LIKE '' THEN 1 ELSE 2 END as int)) + ', ' + CONVERT(nvarchar(max), ISNULL(aff.FUND_NUM_2, 0)) + ', ''' + CONVERT(nvarchar(max), REPLACE(REPLACE(ISNULL(aff.FUND_NAME_SHORT, ''), '\', '\\'), '''', '\''')) + ''', ''' + CONVERT(nvarchar(max), REPLACE(REPLACE(ISNULL(aff.FUND_NAME_FULL, ''), '\', '\\'), '''', '\''')) + ''', ''' + CONVERT(nvarchar(max), REPLACE(REPLACE(ISNULL(aff.ANNOTATE, ''), '\', '\\'), '''', '\''')) + ''', ''' + CONVERT(nvarchar(max), REPLACE(REPLACE(ISNULL(aff.MOVEMENT_NOTE, ''), '\', '\\'), '''', '\''')) + ''', ''' + CONVERT(nvarchar(max), REPLACE(REPLACE(ISNULL(aff.FUND_HISTORY, ''), '\', '\\'), '''', '\''')) + ''', ' + CONVERT(nvarchar(max), ISNULL(aff.DOC_START_YEAR, 0)) + ', ' + CONVERT(nvarchar(max), ISNULL(aff.DOC_END_YEAR, 0)) + ', ' + CONVERT(nvarchar(max), ISNULL(aff.DOC_RECEIPT_YEAR, 0)) + ', ' + CONVERT(nvarchar(max), ISNULL(aff.LAST_CHECKED_YEAR, 0)) + ');' AS NVARCHAR(MAX)) as query | |
FROM [af5_gayo].[dbo].[tblFUND] aff | |
WHERE | |
aff.Deleted <> 1 | |
AND ISNULL(aff.[ISN_SECURLEVEL], 0) <> 2 | |
AND ISNULL(aff.[PRESENCE_FLAG], '') NOT LIKE 'b' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment