What a "GO" statement do in T-SQL ?

Sep 13, 2011 Posted by Lara Kannan 0 comments
What a "GO" statement do in T-SQL ?

By definition it is a batch separator. It will run a batch and commit it. But along with that it also accepts one parameter which tells the SQL engine basically how many times to do the job.

For Example:
SELECT * FROM   sys.objects;
GO 3
It will show the output THREE times :)

Note: "GO" is the keyword used by SSMS to separate query batches. It can be configured in this location:

Tools » Options » Query Execution » SQL Server » General. Change the value for "Batch Separator:" in the right pane.

To see the immediate effect of this change, you need to close all query windows in the current session and open new query window.


Next Example:

IF EXISTS (SELECT 1
FROM tempdb.sys.objects
WHERE name LIKE '%#ProductTable%')
DROP TABLE #ProductTable;

CREATE TABLE #ProductTable
(
ID INT IDENTITY (1, 1),
Name VARCHAR (50)
);
GO

INSERT INTO #ProductTable (Name) VALUES ('Office XP');
GO 3

SELECT * FROM #ProductTable;

OUTPUT:

Hope this helps you and thanks to SQLLion.

Share

Introduction to Script#

Posted by Lara Kannan 2 comments

Have you heard about Script#?

I knew that there is a Java-to-Javascript converter called GWT (Google Web Toolkit) in Java World since long time back and I thought that it might be good if we, the C# developers, also have that kinda tools for ASP.NET web development.

Now C# developers can do the same using Nikhil Kothari's Script# project. This is not quite the same as using Atlas with ASP.NET though both cover similar territory.

Nikhil has written a C# compiler that outputs JavaScript instead of IL code. JavaScript is a powerful but not very friendly scripting language and Ajax is a technology that updates part of web pages from a web server without redrawing the entire page.

Script# is a compiler that generate the Javascript instead of MSIL from C# sourcecode. Like GWT (Google Web Toolkit) that can convert the Java code to browser-compliant JavaScript and HTML, Script# is able to convert the C# codes to Javascript (either human-readable format or compact one). It is the best tool for those who hate to write the Javascript in HTML view.

How it works?

Script# works by compiling C# source code and files directly into a single JavaScript file, in much the same way as the C# compiler that generates MSIL into a single assembly.


The inputs into the C# compiler are your source files, and any referenced assemblies. The referenced assemblies represent either script APIs in existing script files written manually, or script APIs defined within another Script# project with a corresponding generated script file.

The regular C# compiler is used to produce an assembly for your code and the XML doc-comments file that can then be used to produce documentation. The Script# compiler on the other hand generates a .js script file. All the script files - existing and generated – can then be deployed into a Web site or Web application running on any platform for use at runtime without any Script# dependency.

During compilation, the C# compiler and Script# compiler together provide build-time type checking and validation of your code. This helps catch typos and other common script errors at build-time on the development machine as opposed to at runtime on the end-user's machine.

The Script# compiler produces both release and debug versions of your script. The release version is minimized by removing whitespace and by reducing identifier lengths for internal and private members with shorter names. The debug version is formatted for readability and debuggability

The Script# System

Logically speaking there are three layers to the Script# system:

  • The Compiler

  • The Core RunTime

  • The Framework


Script# Compiler - The compiler compiles C# code into JavaScript, and is only needed on the development or build machine. The compiler assumes the existence of APIs defined in the Script# core runtime to represent classes and other OOP constructs defined in the originating C# source code.

Script# Runtime - At development time, the runtime provides the equivalent of mscorlib.dll. It defines various key .NET types such as System.Object, primitive types and other core BCL types needed to author and compile C# source code.

At runtime, the core runtime is a small bootstrapper script file that implements how various OOP constructs are defined and simulated in JavaScript, as well as providing basic extensions to existing JavaScript objects to implement functionality expected by .NET developers.

The default Script# runtime is implemented in sscorlib.dll and its accompanying runtime counterpart sscorlib.js. To use Microsoft ASP.NET Ajax, the equivalent pair consists of aacorlib.dll and MicrosoftAjax.js as its runtime counterpart.

Runtime assemblies shipping with Script# representing other script APIs such as Virtual Earth, RSS Feeds etc. ship in assemblies named ss*.dll.

Script# Framework - The framework is completely optional. The choice of framework also depends on the application and the developer. The compiler itself is not bound or dependent in any way against any particular framework choice. The default ScriptFX framework accompanying Script# ships in assemblies and scripts named ssfx.*.dll and ssfx.*.js.

Using Script#

Script# can be used either via the command-line (ssc.exe) or via MSBuild (via a custom task added to your .csproj profile file). The MSBuild approach is recommended.

Sourcecode Download : SSharp.zip

For more reference click here

Share