Saturday, June 10, 2006

Command Prompt CSharp Compilation

Here is the string for compiling the .cs files c:\bin>csc /t:library fileName.cs.

Sql Server number of tables, procedures etc

Use db1
select count(*) from sysobjects where xtype = 'U' and status > 0
select count(*) from sysobjects where xtype = 'P' and status > 0
Use db2
select count(*) from sysobjects where xtype = 'U' and status > 0
select count(*) from sysobjects where xtype = 'P' and status > 0

Here xtype can also be
Object type. Can be one of these object types:
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
L = Log
FN = Scalar function
IF = Inlined table-function
P = Stored procedure
PK = PRIMARY KEY constraint (type is K)
RF = Replication filter stored procedure
S = System table
TF = Table function
TR = Trigger
U = User table
UQ = UNIQUE constraint (type is K)
V = View
X = Extended stored procedure

Sql Server Table Column counts

It has been a long time since i added anything to the tech blog.

Got one very nice UDF here for finding the number of columns in each table.
Was very useful as i had to upgrade a clients db after a long time.

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE FUNCTION dbo.udf_Tbl_ColCountTAB (

@Table_Name_Pattern sysname = NULL -- Pattern for matching
-- to the table name, Null=all
, @Col_Name_Pattern sysname = NULL -- Pattern for matching
-- to the column name, NULL=all
) RETURNS TABLE
-- NO SCHEMABINDING do to use of INFORMATION_SCHEMA
/*
* Returns a count for the number of columns in each table or
* view that satisfies the Table_Name_Pattern
*
* Example:
select * FROM dbo.udf_Tbl_ColCountTAB (null, null)
*
*/
AS RETURN

SELECT TOP 100 PERCENT WITH TIES
c.TABLE_NAME
, COUNT(*) NumColumns
FROM INFORMATION_SCHEMA.[COLUMNS] c
inner join INFORMATION_SCHEMA.[TABLES] t
ON C.TABLE_SCHEMA = t.TABLE_SCHEMA
and c.TABLE_NAME = T.TABLE_NAME
WHERE TABLE_TYPE = 'BASE TABLE'
and 0=OBJECTPROPERTY(OBJECT_ID(t.TABLE_NAME),
'IsMSShipped')
and (@Table_name_pattern IS NULL
or c.TABLE_NAME LIKE @Table_Name_Pattern)
and (@Col_Name_Pattern IS NULL
or c.COLUMN_NAME LIKE @Col_Name_Pattern)
GROUP BY c.TABLE_NAME
ORDER BY c.TABLE_NAME

GO

GRANT SELECT ON dbo.udf_Tbl_ColCountTAB to PUBLIC
GO

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Wednesday, June 07, 2006

பிரசாந்த்

பிரசாந்த்

Wow that is actually my name in Tamil. It is cool that it is being shown since it is in Unicode

http://home.att.net/~jameskass/keybtaml.htm

Used this link to paste it