Server Side Scripts and Client Side Scripts are different things but both Scripts are constructed using the same T-SQL queries. These both scripts are constructed using Data Definition Language (DDL) , Transaction Control (TCL) , Data Manipulation Language (DML) ,Data Control Language (DCL) ,If else and some Logic conditions internally. Both the Scripts will get executed on database through Database Engine.
Server Side SQL Script is nothing but Pre-compiled statements. Pre-compiled Statements or Scripts is nothing but they will only get compiled at the first time execution of that and then they are stored on databases. Pre-compiled Statement means they only consider pre-compile for the second time at first they are not pre-compiled.
Example for Server Side Scripts are Stored Procedure , Triggers ,Views etc .
Store Procedure and Trigger will take long time to compile at first time. After that they will give results so fast. After running the server side SQL , the entry for the cache is made in the system.
Client Side Script is known as dynamic SQL i.e SQL that is contained within the application. This is nothing but DML,DDL command execute on database. We will use this scripts each time when data modification and record insertion into database objects. Client Side SQL will run each time whenever it is get executed against database.
Which is Best ?
If a statement is used multiple times in an application, precompiling it, provides better performance than sending it to the database and compiling it for each time. The more complex the statement, the greater, the performance benefit.
If a statement is likely to be used only a few times, precompiling it may be inefficient because of the overhead involved in precompiling, saving, and later deallocating it in the database. Precompiling a dynamic SQL statement for execution and saving it in memory uses time and resources. If a statement is not likely to be used multiple times during a session, the costs of doing a database prepare may outweigh its benefits. Another consideration is that once a dynamic SQL statement is prepared in the database, it is very similar to a stored procedure.
In some cases, it may be preferable to create stored procedures and have them reside on the server, rather than defining prepared statements in the application.
Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.