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!
If you're using a verbatim string (i.e. defined with the @ sign before the opening quotes) then you can just press the return key in the middle of the definition, for example:
string QueryString = @"select dbName.dbo.ScalarFunction()
union
select dbName2.dbo.ScalarFunction()";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With