Hello,
Just wondering how you all deal with writing large SQL strings when coding
database functionailty. Some of the SQL strings can get quite long and it
looks a bit messy and hard to read in the code. Is there a good way to write
the SQL so it remains neat, clear, readable and manageable?
Also, being new to VS 2005, is there a way in which SQL commands can be
tested in the Query browser and then 'parcelled up' automatiallt as
individual functions available for use throughout the app?
Thanks for any views,
Best regards,
David Ross 5 1207
Hello,
>
Just wondering how you all deal with writing large SQL strings when coding
database functionailty. Some of the SQL strings can get quite long and it
looks a bit messy and hard to read in the code. Is there a good way to write
the SQL so it remains neat, clear, readable and manageable?
Also, being new to VS 2005, is there a way in which SQL commands can be
tested in the Query browser and then 'parcelled up' automatiallt as
individual functions available for use throughout the app?
Thanks for any views,
Best regards,
David Ross
A better coding practice would be to put all those "sql strings" into
stored procedures, and call them (using parameters of course).
This way SqlServer can even precompile the sql-code, for better
performance.
Hans Kesting
"Hans Kesting" wrote:
Hello,
Just wondering how you all deal with writing large SQL strings when coding
database functionailty. Some of the SQL strings can get quite long and it
looks a bit messy and hard to read in the code. Is there a good way to write
the SQL so it remains neat, clear, readable and manageable?
Also, being new to VS 2005, is there a way in which SQL commands can be
tested in the Query browser and then 'parcelled up' automatiallt as
individual functions available for use throughout the app?
Thanks for any views,
Best regards,
David Ross
A better coding practice would be to put all those "sql strings" into
stored procedures, and call them (using parameters of course).
This way SqlServer can even precompile the sql-code, for better
performance.
Hans Kesting
Thanks Hans!
That sounds like a good approach. I'll give it a shot!
Cheers,
David
David++,
Hans' idea of using stored procs is a good one.
However, if you still must use long SQL from your app, one idea is to add
the SQL into a text file (eg. YourSQL.sql), then add the text file as an
embedded resource to your project. Then you can read the resource from your
code.
HTH,
Stephen
"David++" <Da***@discussions.microsoft.comwrote in message
news:0A**********************************@microsof t.com...
Hello,
Just wondering how you all deal with writing large SQL strings when coding
database functionailty. Some of the SQL strings can get quite long and it
looks a bit messy and hard to read in the code. Is there a good way to
write
the SQL so it remains neat, clear, readable and manageable?
Also, being new to VS 2005, is there a way in which SQL commands can be
tested in the Query browser and then 'parcelled up' automatiallt as
individual functions available for use throughout the app?
Thanks for any views,
Best regards,
David Ross
"Stephen Ahn" wrote:
David++,
Hans' idea of using stored procs is a good one.
However, if you still must use long SQL from your app, one idea is to add
the SQL into a text file (eg. YourSQL.sql), then add the text file as an
embedded resource to your project. Then you can read the resource from your
code.
HTH,
Stephen
"David++" <Da***@discussions.microsoft.comwrote in message
news:0A**********************************@microsof t.com...
Hello,
Just wondering how you all deal with writing large SQL strings when coding
database functionailty. Some of the SQL strings can get quite long and it
looks a bit messy and hard to read in the code. Is there a good way to
write
the SQL so it remains neat, clear, readable and manageable?
Also, being new to VS 2005, is there a way in which SQL commands can be
tested in the Query browser and then 'parcelled up' automatiallt as
individual functions available for use throughout the app?
Thanks for any views,
Best regards,
David Ross
Thanks Stephen,
I'll look into that option as well.
Cheers,
David
Hans Kesting wrote:
A better coding practice would be to put all those "sql strings" into
stored procedures, and call them (using parameters of course).
This way SqlServer can even precompile the sql-code, for better
performance.
You might wish to hold off on automatically putting all SQL queries in
stored procedures. There is some debate about this practice. I'm
still kind of middle of the road on it, but look at this article: http://weblogs.asp.net/fbouma/archiv.../18/38178.aspx
As an alternative, what we have done is create a shared class called
SqlQuery with shared string constants that contain parameterized SQL
queries and then use that in our code (watch for typos):
Shared Class SqlQuery
Shared Const Query1 As String = "SELECT * FROM Table WHERE Column =
'ABC'"
End Class This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gordon Airport |
last post by:
Has anyone suggested introducing a mutable string type (yes, of course)
and distinguishing them from standard strings by the quote type - single
or double? As far as I know ' and " are currently...
|
by: Xah Lee |
last post by:
i had the pleasure to read the PHP's manual today.
http://www.php.net/manual/en/
although Pretty Home Page is another criminal hack of the unix lineage,
but if we are here to judge the quality...
|
by: dmh2000 |
last post by:
I recently complained elsewhere that Python doesn't have multiline
comments. i was told to use triple quoted strings to make multiline
comments. My question is that since a triple quoted string is...
|
by: Kza |
last post by:
Hi, just in the process of maintaining some software that used some
funy old string library and char*s , and we are updating everything to
use std::strings. (or should I say std::basic_string<>s)
...
|
by: scroopy |
last post by:
Hi,
I've always used std::string but I'm having to use a 3rd party library
that returns const char*s. Given:
char* pString1 = "Blah ";
const char* pString2 = "Blah Blah";
How do I append...
|
by: arnuld |
last post by:
i was doing exercise 4.3.1 - 4.29 of "C++ Primer 4/e" where authors,
with "run-time shown", claim that C++ Library strings are faster than
C-style character strings. i wrote the same programme in...
|
by: rmr531 |
last post by:
First of all I am very new to c++ so please bear with me. I am trying
to create a program that keeps an inventory of items. I am trying to
use a struct to store a product name, purchase price,...
|
by: Andreas Beyer |
last post by:
Hi,
I found the following quite cryptic code, which basically reads the
first column of some_file into a set.
In Python I am used to seeing much more verbose/explicit code. However,
the example...
|
by: John Brock |
last post by:
I have a .NET application that, among other things, creates Excel
workbooks, and I have run into a very strange problem involving
formulas on one worksheet that reference values on another...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |