Generate empty line (null) in sql server

1

I do not know much about sql, but I need to do the following:

  • User informs a number.
  • Sql generates the amount entered by the user of blank / null records.
  • After generating the blank records, execute an sql query.

In the last item the sql query I can do. But I need to know how to run only after I've finished generating the blank records.

Case : The library uses a label sheet containing 30 labels. So if she used 5 sheet labels, I need 5 blank records to print nothing and from the sixth record start printing the query result.

    
asked by anonymous 06.04.2017 / 17:33

1 answer

1

You can generate a table with numeric sequences (omitting your data) and merge with your original search. TOP 10 will specify how much you want.

WITH gerador (id) AS (
     SELECT 1
     UNION ALL
     SELECT id + 1
     FROM gerador
     WHERE id < 1000000
  )
  SELECT TOP 10 NULL 'CAMPO_1', NULL 'CAMPO_2', NULL 'CAMPO_3' FROM gerador
  UNION ALL
  SELECT SEU_CAMPO_1, SEU_CAMPO_2, SEU_CAMPO_3 FROM SUA_TABELA
  OPTION ( MAXRECURSION 0 )
GO
    
06.04.2017 / 17:51