15

I have a database in Microsoft SQL Server and I am using Microsoft SQL Server Management Studio.

I have an option to insert the query result to the file, although the results of the query are not separated by any special signs.

It looks like this

select * from table_name

Output:

18 182 3386 NULL
18 790 12191 NULL

In File:

18          182         3386        NULL
18          790         12191       NULL

Is there any possibility to modify query so after every record it will put a special char, like this:

In File:

18;          182;         3386;        NULL;
18;          790;         12191;       NULL;

It will be easier then for me to copy this database to other programs.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
MateuszC
  • 481
  • 2
  • 5
  • 14

3 Answers3

37

Click here

Click here on your SSMS before you execute your query.

M.Ali
  • 67,945
  • 13
  • 101
  • 127
  • This is what I had accidentally hit! Hart CO's answer was set correctly in my options but the button above was toggled to text response. – BYUDigger Oct 25 '19 at 22:33
17

In SSMS:

Tools > Options > Query Results > Results To Text

Top option there is Output Format, can set a delimiter there.

Hart CO
  • 34,064
  • 6
  • 48
  • 63
8

CTRL+T Then Execute , = Text Result CTRL+D Then Execute , = Grid Result

  • This is what I needed! For some reason it seems that if you used the key commands (which I did by mistake), setting through Query Results in Tools doesn't fix it. I had to use CTRL+D to get out of text results. – LeftOnTheMoon Mar 06 '20 at 02:22