Archives by Tag 'SQL'
MSSQL : List all tables with size and row count
It comes to be very handy while analyzing the database tables.
Here is a quick and dirty script lists all the tables and their rows counts, data size.
DECLARE @table table(Id int IDENTITY(1,1)
, Name varchar(256))
INSERT INTO @table
SELECT b.name + ‘.’+ a.name
FROM sys.tables a INNER JOIN sys.schemas b
ON a.schema_id = b.schema_id
INSERT INTO @table
SELECT ‘-1′
DECLARE @result table( TableName varchar(256)
, TotalRows [...]
SQL XML, select from xml using nodes() function
Very handy function that helps me move small data around.
DECLARE @myXml AS XML
SET @myXml =
‘<ArrayOfProduct>
<Product id="1">
<Description>test1</Description>
</Product>
<Product id="2">
<Description>test2</Description>
</Product>
</ArrayOfProduct>
‘
SELECT
[...]
