Archive for January, 2008

Find row count of one or more tables

Saturday, January 5th, 2008

Find row count of one or more tables The following code can be used to retrieve the rowcount of each tables in the database. Let us create a function (TABLE VALUED) which returns the row count of all the tables. CREATE FUNCTION dbo.GetRowCount() RETURNS TABLE RETURN SELECT st.Name, ...

Online DTD Validators

Saturday, January 5th, 2008

I had been creating some DTDs for a book that I am currently writing. The book is not about DTD. The title of the book is "XSD For SQL Server 2005 Developers" and it aims at helping SQL Server 2005 developers to make effective use of XML ...

VARCHAR/NVARCHAR (N) vs (MAX)

Saturday, January 5th, 2008

Prior to SQL Server 2005, it was hard dealing with large string values. NVARCHAR and VARCHAR data types had a limitation of 8000 bytes (VARCHAR(8000) and NVARCHAR(4000)). To store large values, most people used TEXT columns and others broke the value into multiple rows. Dealing with ...

Application Roles in SQL Server

Saturday, January 5th, 2008

Application roles are set of permissions that you can group together for a specific application. When a user connects to the database through the specific application, he or she will be able to perform the actions permitted under the specific application role. I have not used application ...

How to find all stored procedures used by Report Server?

Saturday, January 5th, 2008

Report definitions [RDL files] are stored in the "catalog" table of ReportServer database. This table has a field "content" which stores the report definition as an image/text value. The following query will extract a list of all reports and the stored procedures used by them, by querying ...

Insert an XML variable into another

Friday, January 4th, 2008

If you are using SQL Server 2008 November CTP, you can insert one XML variable into anther using the XQuery insert operator. Here is an example: -- declare an XML variable DECLARE @x XML SET @x = '<Root></Root>' -- create another XML variable DECLARE @t XML SELECT @t = (SELECT TOP 3 name FROM ...