Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any online tool for converting sql statements to string format? [closed]

Tags:

string

sql

format

I'm looking for a simple tool for sql formatting. For example:

SELECT 
    Something
FROM
    Sometable

is going to be converted as (for vb):

MyVar = "SELECT " & _
    "Something " & _
    "FROM " & _
    "Sometable "

Does anyone know any online tool for this?

Thanks..

like image 216
bilge do Avatar asked Apr 02 '12 13:04

bilge do


2 Answers

If you're simply looking for a solution to convert a multi-line query to VB.NET's string format, this solution doesn't need to be specific to SQL.

You could use a VS Macro, such as this one, for converting the string to VB.NET format, and adding the appropriate & _ characters.

If you're looking for an online tool, this page converts C# code to VB.NET code. If you simply enter a string in C# format, such as:

@"SELECT 
    Something
FROM
    Sometable"

The tool will create the following VB.NET string:

"SELECT " & vbCr & vbLf & "    Something" & vbCr & vbLf & "FROM" & vbCr & vbLf & "    Sometable"
like image 131
Michael Fredrickson Avatar answered Sep 20 '22 13:09

Michael Fredrickson


XML Literals work awesomely if you just want to include the query exactly in your code:

Dim s As String = <a><![CDATA[
  SELECT 
      Something
  FROM
      Sometable
]]></a>.Value

I found this method by searching for a way to do multiline strings in vb. The best answer is here.

like image 35
Brandon Avatar answered Sep 19 '22 13:09

Brandon