Creating SQL query with line breaks in a single string

c#, sql, ssms

Solution

i dont think you need to worry about the newline

@"select dbName.dbo.ScalarFunction() union select dbName2.dbo.ScalarFunction()"

Problem

In the SQL Server Management Studio I create a new query and then I run the following code: ``` select dbName.dbo.ScalarFunction() union select dbName2.dbo.ScalarFunction() ``` Then I try to do the same thing from my C# program. However I am having trouble to translate the above to one Query string. I have tried the following, but without any success: ``` string QueryString = @"select dbName.dbo.ScalarFunction() /r/n union /r/n select dbName2.dbo.ScalarFunction()" ``` and ``` string QueryString = @"select dbName.dbo.ScalarFunction(); union; select dbName2.dbo.ScalarFunction();" ``` and ``` string QueryString = @"select dbName.dbo.ScalarFunction(); union select dbName2.dbo.ScalarFunction();" ``` I am very new to SQL so if anyone could help me with the correct syntax I would be very happy! Thanks in advance!

Original source