background preloader

Sql

Facebook Twitter

Array

T-SQL New features in SQL Server 2005 - Part 4. Have you ever come across a situation where you need to delete data from one table and keep the deleted records in another table? Or insert data in one table and also add the new rows at the same time to another? Weird situation...but this is what I had to do while writing a stored procedure that operates on some physical table and also keep track of affected records in another table(a table data type variable, to be precise) so that I can do some more manipulations on that.

This approach, of keeping two tables(a physical and a table type variable)in sync with each other, is definitely not a clean approach but comes in handy when you know that you will be working on a very small subset of a table containing thousands of rows. Output Clause SQL Server 2005 provides a new clause known as "Output". Suppose we have a table called Employees and we wish to insert a new record into it and also get the ID of the inserted record, which we want to return to the client of our stored procedure. Violation of PRIMARY KEY constraint 'PK_PrimaryKeyName&#039. How To Use SQL Server to Analyze Web Logs.

Internet Information Server/Services provides a number of formats to gather data in the form of web logs. For busy sites, these text-based flat files sometime become too much of burden to review and are ignored. A better way to review the data would make these logs a better resource for administrators and web masters.

This article describes a method to import IIS logs in World Wide Web Consortium (W3C) Extended Logging format into Microsoft SQL Server to facilitate the review of the IIS log files. The techniques provided can also be altered for other log file formats. Web logs are delimited text files as specified by RFC 2616, "Hypertext Transfer Protocol -- HTTP/1.1" ( ( The logs are formatted as follows: Collapse this tableExpand this table CREATE TABLE [dbo]. Note that some of these fields are quite large and may not be necessary for reviewing your particular log files.

BULK INSERT [dbo]. Another sample query: Using LINQ to XML (and how to build a custom RSS Feed Reader wit. One of the big programming model improvements being made in .NET 3.5 is the work being done to make querying data a first class programming concept. We call this overall querying programming model "LINQ", which stands for .NET Language Integrated Query. LINQ supports a rich extensibility model that facilitates the creation of efficient domain-specific providers for data sources. .NET 3.5 ships with built-in libraries that enable LINQ support against Objects, XML, and Databases.

What is LINQ to XML? LINQ to XML is a built-in LINQ data provider that is implemented within the "System.Xml.Linq" namespace in .NET 3.5. LINQ to XML provides a clean programming model that enables you to read, construct and write XML data. LINQ to XML provides much richer (and easier) querying and data shaping support than the low-level XmlReader/XmlWriter API in .NET today. Using LINQ to XML to query a local XML File from feed in feedXML.Decedents("Feed") Hmm - What is this "anonymous type" thing?

Summary Scott. Mike Taulty&#039;s Blog : LINQ to Video #18. LINQ to SQL (Part 9 - Using a Custom LINQ Expression with the &l. Over the last few weeks I've been writing a series of blog posts that cover LINQ to SQL. LINQ to SQL is a built-in O/RM (object relational mapper) that ships in the .NET Framework 3.5 release, and which enables you to model relational databases using .NET classes. You can use LINQ expressions to query the database with them, as well as update/insert/delete data. Below are the first eight parts in this series: In Part 5 of the series I introduced the new <asp:LinqDataSource> control in .NET 3.5 and talked about how you can use it to easily bind ASP.NET UI controls to LINQ to SQL data models. I also demonstrated how to use it a little more in a follow-up post I did that discusses the new <asp:ListView> control (Part 1 - Building a Product Listing Page with Clean CSS UI).

In both of these articles the queries I performed were relatively straight-forward (the where clause worked against a single table of data). Quick Recap: <asp:LinqDataSource> with a Declarative Where Statement Summary Scott.