Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
The Voice of the DBA
 

Daily Coping Tip

Enjoy photos from a time with happy memories

I also have a thread at SQLServerCentral dealing with coping mechanisms and resources. Feel free to participate.

For many of you out there working in a new way, I'm including a thought of the day on how to cope in this challenging time from The Action for Happiness Coping Calendar. My items will be on my blog, feel free to share yours.

Your Thoughts On In-line SQL

Today we have a guest editorial as Steve is on vacation. This editorial was originally published on Mar 16, 2018.

I want to start with my definition of in-line SQL. I define it as any SQL statement, such as: selects, inserts, updates, or deletes, where they exist in text form in an application.

I think there are really two opinions on this issue. There people that hate in-line SQL and then those that think it is great. I would guess that some of you, that are reading this article, are DBA’s and wish there was no in-line SQL in the applications or databases you support. Others of you are on more of the developer spectrum might like in-line SQL in your application. Personally, I think that in-line SQL should only be used in the rarest of situations where something just cannot be easily done without it. Basically, I prefer and advocate using stored procedures only for application access to the database.

Clearly, using stored procedures only in an application can help with security. Both in the rights you need to give users and to protect from SQL injection attacks. Still, there is another reason I think stored procs are better for application data access. I have found that when there are bugs or changes that are needed, there are many cases where just the stored proc can be changed and released instead of a new build of the application. I can’t tell you how many times we have been able to quickly test and release a stored proc change verses trying to get a new build of an application out.

So why do people use in-line SQL?  I know of a situation from a few years ago where the DBA was so slow to release changes to the database, the developers finally got tired of it and just moved everything to in-line SQL so they could better control releases and bug fixes. I am not sure if that is what the DBA wanted or not, but it was the result of the developers wanting more control to get releases / bug fixes out. I still don’t like in-line SQL, but I can see why someone could be driven to use it, just to try and get things done.

I think sometimes people use in-line SQL because it is less work at first. It is certainly more work to create the stored procedure, verses just drop a SQL statement into the application code. Still, I think it is less work only in the beginning. In the long run I believe stored procedures are less work and are easier to support over the life of an application.

Another good reason to use stored procedures only in an application is to be able to check dependencies. When all your database access exists only in stored procedures you can easily search those stored procs to find out how some change to the schema might affect existing SQL statements. When SQL statements are in-line they can be all over the place in code and not as easy to search accurately for them.

In the end you have to make the best decision you can for your situation and company. So how about you? What do you think about in-line SQL verses stored procs for database access in an application?

bkubicek

Join the debate, and respond to today's editorial on the forums

 
 Featured Contents
SQLServerCentral Article

How to Visualize Python Charts in Power BI Part 4

Daniel Calbimonte from SQLServerCentral

In this fourth part of the series, we look at various other plot types in Power BI using Python.

Technical Article

Time to register for PASS Data Community Summit

Additional Articles from PASS

The schedule at a glance is now available. Get ready for a week of learning and connecting at the data community homecoming. LAST chance to benefit from Late Bird prices for online and in-person passes.

External Article

[Video] Fragmentation Explained in 20 Minutes at SQLBits

Additional Articles from Brent Ozar Unlimited Blog

What does fragmentation mean? How does it happen? Can you fix it with fill factor? Should you rebuild your indexes to fix it?

Blog Post

From the SQL Server Central Blogs - T-SQL Tuesday #154 – SQL Server 2022

gbargsley from GarryBargsley

This month’s T-SQL Tuesday is being hosted by Glenn Berry , and the subject he chose is “SQL Server 2022.”  Microsoft has recently released the RC0 version of SQL...

Blog Post

From the SQL Server Central Blogs - Learning PostgreSQL: The Tools

Grant Fritchey from The Scary DBA

In case you don’t know, I’ve been writing a series of articles over on Simple-Talk as I learn PostgreSQL. It’s all from the point of view of a SQL...

 

 Question of the Day

Today's question (by tomaz.kastrun):

 

Using R apply

Using famous IRIS dataset, which result this APPLY function returns:
apply(iris[,1:4], 1, sum)

Think you know the answer? Click here, and find out if you are right.

 

 

 Yesterday's Question of the Day (by Steve Jones - SSC Editor)

Removing a Column

I added a new column to a table with this code:

ALTER TABLE dbo.Summit2022 ADD QuoteByURL VARCHAR(200)

While I think this is a good idea, it needs to be tested by others and reviewed. Because this might be an issue, I also want an undo script that can be run to remove this change if it's a problem. What should I put in the undo script?

Answer: ALTER TABLE dbo.Summit2022 DROP COLUMN QuoteByURL

Explanation: While the ADD to a table works without without the COLUMN, the DROP requires the COLUMN keyword. Ref: ALTER TABLE - https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql?view=sql-server-ver16

Discuss this question and answer on the forums

 

 

 

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.


SQL Server 2016 - Development and T-SQL
How to calculate time difference? - Hello everyone, I have a table logs which maintains file names and date and time at which they were loaded into Sql server database table. The table looks like this: S.No Step_name File_name Date_time Minutes_difference 1 File Loaded Individual_1.xml 9-15-22 10:50 AM ? 2 File Loaded Individual_2.xml 9-15-22 11:00 AM ? 3 File Loaded Individual_3.xml […]
SQL Server 2012 - T-SQL
Tsql batch script does not stop - We have the following update script we are trying to do in batches. Currently the execution never stops running - so needed help understanding what's wrong with the logic or syntax thats missing. -Create Temp table create table #TempIFSC ( [EnrolledPaymentMethodAccountId] uniqueidentifier, [PaymentAccountId] uniqueidentifier, [ExternalSystemId] int, [EnrolledPaymentMethodAccountStatusId] int, [Extension] xml, [EnrollmentAccountRevisionId] int, [BankName] NVARCHAR(100) NULL, […]
SQL Server 2019 - Administration
Log shipping TO Always On Availability Group? - Hi, I've been trying to find the answer on the internet but was not successful. I don't have the setup done yet (hence can't try it out) but this is basically how it's going to look like: Produktion: 2 servers - Always On Availability Group - SQL 2019 Standard Edition hence no secondary read only […]
Dynamic column result data - Hi, First of all pls don't comment on table structure. its already created we cannot change anything. I have 3 table like below. ##Invoice (which has the unique data) and ##ReInvoice (we will submit until its get fully paid. here we maintain level) and ##Payment (which has the payment history also maintain level) create table […]
host-based authentication possible? - Hi! is  host-based authentication possible? e.g. : userA is allowed to login from 192.168.80.0/24 userB is allowed to login only from 127.0.0.1 userC is allowed to login from any host    
backup practice/strategy/risks - I have a current job that does FULL backup to all my USER DBs daily and system DBs weekly.  I do not do DIFF at all.  only Log for those full recovery model. Are there any risks to this practice when it comes to restoring in case i need to. Thanks  
SQL Server 2019 - Development
a good book on SQL - Hello! Would someone please recommend a good book on SQL development? As an example, I consider "C# 10 in a Nutshell" by Joseph Ablahari a good book. Though concise, it covers lots of material.
How to get Key based on type and sub type - I Have sample data that looks like below. We have similar data like below for ton's of different keys.  for each key data will be like 5 to 6 rows based on type and sub type ; I need to get the Key from the below records where the data set contain type COLL and […]
How to change STRING_AGG to stuff xml to split feature value by pip? - I work on sql server 2019 . i can't write query below with stuff for xml . so how to change STRING_AGG to stuff xml ? query below take too much time so i need to try with stuff for xml to reduce time cost . query i try it select a.RecomendationId, cast(STRING_AGG(cast(f1.FeatureValue as varchar(300)) ,'|') WITHIN GROUP (ORDER BY f1.FeatureId ASC) as […]
Working with Oracle
Is each serializable schedule view serializable? - We are aware that conflict serializability is a valid subset of view serializability in DBMS Schedules of Transactions. However, all serializable schedules may be included in view serializable schedules. A suitable subset of view serializability, maybe, or another option? Has this been examined?
General Cloud Computing Questions
Suggest cloud provider for SQL - I am a MERN stack developer and we need to work with SQL for a project. Can anyone suggest a good FREE cloud SQL server having low storage with which my Node backend can connect using an URI (Like Atlas for MongoDB). Our backend developer is left in the dark with this sudden and urgent […]
Reporting Services
Exporting user names and passwords - We are in the process of moving SSRS 2104 web servers in a scale out deployment from one domain to another. The unfortunate thing is that the production environment is not even close to the lower environments, mainly because of some really bad practices that I inherited and subsequently stopped from happening.  So, we were […]
General
script task and excel format syntax - Hello, I'm a newbie to script tasks and new some assistance. When using SSIS/script task, I have the following code which creates excel files in xls format. However, I would like to create them in xlsx format - what do I need to change in the code. Thank you.   Public Sub Main() Dim url, […]
Integration Services
Use ForEachLoop to split data by unique field in source and create an excel file - Hello, I'm trying to create excel files that hold data for each Invoice Id by using a Foreach Loop Container (FLC). I have successfully created the source query that lists all the distinct invoice Id's with results held in a variable (Result Set). Then successfully configured FLC to be a Foreach ADO enumerator and picking […]
Administration
EventID - 833 - Hi, We have Sql server 2005. User databases are in one drive and system databases are in C:/ drive. We are gettting alerts about Event ID: 833 from both user databases and system databases? Is surely indicate IO issues?
 

 

RSS FeedTwitter

This email has been sent to {email}. To be removed from this list, please click here. If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com. This newsletter was sent to you because you signed up at SQLServerCentral.com.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
webmaster@sqlservercentral.com

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -