Search This Blog

2010-03-29

Today's lessons

  1. Generation code needs more testing
  2. Generators tent to behave differently depending on the types they are handling = hidden bugs
  3. Test more , publish less

A nice link for ASCII set tables

SOURCES:
A nice ASCII set table link

Function to get the C# type based on the tsql type



/****** Object:  UserDefinedFunction [dbo].[funcGetCLRTypeBySqlType]    Script Date: 03/23/2010 15:25:09 ******/
IF  EXISTS (SELECT * FROM sys.objects 
WHERE object_id = OBJECT_ID(N'[dbo].[funcGetCLRTypeBySqlType]') 
AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[funcGetCLRTypeBySqlType]
GO
 
/****** Object:  UserDefinedFunction [dbo].[funcGetCLRTypeBySqlType]    
 
Script Date: 03/23/2010 15:25:09 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
CREATE FUNCTION [dbo].[funcGetCLRTypeBySqlType](
@SqlType [nvarchar] (200)
)
 
RETURNS [varchar](200) WITH EXECUTE AS CALLER
AS 
BEGIN
declare @ClrType varchar(200)
 
--EXEC PROCuTILS_rOWcOLS 'DbVsCSharpTypes'
SET @ClrType = ( SELECT  TOP 1 CSharpDataType FROM DbVsCSharpTypes 
WHERE Sql2008DataType= @SqlType)
-- Return the result of the function
RETURN @ClrType
 
END
 
/*
<doc>Used for automatic conversation between tsql and C# types </doc>
*/
GO
/*
select dbo.funcGetCLRTypeBySqlType('varchar')
 
*/

how-to generate classes based on tables in ms sql 2008 ( see previous posts )



/****** Object:  StoredProcedure [dbo].[procUtils_GenerateClass]    
Script Date: 03/20/2010 13:10:40 ******/
IF  EXISTS (SELECT * FROM sys.objects 
WHERE object_id = OBJECT_ID(N'[dbo].[procUtils_GenerateClass]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[procUtils_GenerateClass]
GO
 
/****** Object:  StoredProcedure [dbo].[procUtils_GenerateClass]    
 
Script Date: 03/20/2010 13:10:40 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
 
CREATE PROCEDURE [dbo].[procUtils_GenerateClass]
@TableName [varchar](50)
WITH EXECUTE AS CALLER
AS
BEGIN -- proc start                                      
SET NOCOUNT ON;                                      
 
DECLARE @DbName nvarchar(200 ) 
DECLARE @CSharpDataType nvarchar(200)
select @DbName = DB_NAME()               
declare @strCode nvarchar(max) 
set @strCode = ''
 
-- use this variable while generating code 
DECLARE @WinNewLine nvarchar(2)
set @WinNewLine = CONVERT ( nvarchar(2) , CHAR(13) + CHAR(10))
 
-- this is a horizontal tab
DECLARE @Tab nvarchar(1)
set @Tab = CONVERT(NVARCHAR(1) , CHAR(9))
 
SET @DbName = 'Cas'
 
BEGIN TRY        --begin try                            
 
set @strCode = @strCode +  'using System ;  ' + @WinNewLine + @WinNewLine
 
set @strCode = @strCode +  'namespace ' + @DbName + '.Model  {' + @WinNewLine  
set @strCode = @strCode +  'public class ' + @TableName + @Tab +  '{ ' + @WinNewLine  + @WinNewLine
set @strCode = @strCode +  @WinNewLine + '#region FieldsAndProps ' + @WinNewLine + @WinNewLine
--CODE SNIPPET TO LIST TABLE COLUMNS           
-- RUN IN SSMS WITH cTRL + t FIRST TO OUTPUT THE RESULT TO TEXT FOR COPY PASTE          
--FIRST SEARCH THE TABLE WHICH HAD A "Feature" in its name           
--SELECT NAME FROM SYS.TABLES WHERE NAME LIKE '%Feature%'          
--select column_name from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='Feature'              
DECLARE @ColNames TABLE                                
(                                
Number [int] IDENTITY(1,1), --Auto incrementing Identity column                              
ColName [varchar](300) , --The string value                        ,         
DataType varchar(50) ,  --the datatype                       
IS_NULLABLE nvarchar(5) , --should we add =null in front         
CHARACTER_MAXIMUM_LENGTH INT        
)                                
--Decalre a variable to remember the position of the current delimiter                                
DECLARE @CurrentDelimiterPositionVar INT                                 
DECLARE @PkColName varchar(200)      
set @PkColName = ''
declare @ColumnName varchar(200)  
--Decalre a variable to remember the number of rows in the table                                
DECLARE @Count INT                                
--Populate the TABLE variable using some logic                                
-- SELECT * from INFORMATION_SCHEMA.COLUMNS                             
 
--SET IDENTITY_INSERT ON ; 
INSERT INTO @ColNames         
SELECT column_name ,  Data_type , IS_NULLABLE , CHARACTER_MAXIMUM_LENGTH  
from INFORMATION_SCHEMA.COLUMNS                             
where TABLE_NAME=@TableName                                
--Initialize the looper variable                                
SET @CurrentDelimiterPositionVar = 1                                
--Determine the number of rows in the Table                                
SELECT @Count=max(Number) from @ColNames                                
--A variable to hold the currently selected value from the table                                
DECLARE @ColName varchar(300);                                
DECLARE @DataType varchar(50)                      
DECLARE @IS_NULLABLE VARCHAR(5)        
DECLARE @CHARACTER_MAXIMUM_LENGTH INT        
-- START GENERATING PROPERTIES   
--Loop through until all row processing is done              
WHILE @CurrentDelimiterPositionVar <= @Count --1st loop        
BEGIN                                
--Load current value from the Table                                
SELECT @ColName = ColName FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar        
SELECT @DataType = DataType FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar               
SELECT @IS_NULLABLE = IS_NULLABLE FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar                    
SELECT @CHARACTER_MAXIMUM_LENGTH = CHARACTER_MAXIMUM_LENGTH FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar                    
 
IF @DataType = 'timestamp'        
begin 
SET @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1;                                
continue ; 
end 
 
 
 
-- get the C# type based on the passed sqlType, )( needs the DbVsCSharpTypes table ) 
set @CSharpDataType=( SELECT  dbo.funcGetCLRTypeBySqlType(@DataType) )
 
 
 
DECLARE @varPrivate nvarchar(200) 
set @varPrivate = '_' + @ColName 
 
 
 
-- GENERATE THE START REGION PART 
SET @strCode = @strCode + @WinNewLine + @Tab+ @Tab + '#region ' + @ColName + @WinNewLine + @WinNewLine 
 
-- set the nullable 
IF @IS_NULLABLE = 'YES'  and @CSharpDataType <> 'string'      
SET @StrCode = @strCode +   'private ' + @CSharpDataType + '? ' +  @varPrivate + ' ;' + @WinNewLine 
ELSE 
SET @StrCode = @strCode +   'private ' + @CSharpDataType + ' ' +  @varPrivate + ' ;' + @WinNewLine 
 
 
 
 
 
-- GENERATE THE PUBLIC MEMBER 
IF @IS_NULLABLE = 'YES'  and @CSharpDataType <> 'string'
SET @StrCode = @strCode +   'public ' + @CSharpDataType +  '? ' + @ColName + @WinNewLine + '{' + @WinNewLine
ELSE 
SET @StrCode = @strCode +   'public ' + @CSharpDataType +  ' ' + @ColName + @WinNewLine + '{' + @WinNewLine
 
SET @StrCode = @strCode + @Tab + @Tab + 'get { return ' + @varPrivate + '; } ' 
SET @strCode = @strCode + @Tab + @Tab + 'set { ' + @varPrivate +' = value ; }' + @WinNewLine 
SET @strCode = @strCode + @Tab + '} //eof prop ' + @ColName + @WinNewLine 
 
-- GENERATE THE ENDREGION PART FOR THE PROPERTY
SET @strCode = @strCode + @WinNewLine + @Tab + @Tab + '#endregion ' + @ColName  + @WinNewLine
 
 
--if @CurrentDelimiterPositionVar != @Count         
--SET @StrCode = @StrCode + ''        
 
--PRINT @StrCode         
--DEBUGGING        
--PRINT '@ColName - ' + @ColName         
--PRINT '@CSharpDataType - ' + @CSharpDataType                  
--PRINT '@IS_NULLABLE - ' + @IS_NULLABLE         
--PRINT '@CHARACTER_MAXIMUM_LENGTH - ' +  CONVERT ( VARCHAR , @CHARACTER_MAXIMUM_LENGTH )   
 
set @strCode = @strCode + @WinNewLine     
SELECT @strCode 
SET @strCode = ''
SET @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1;                                
END   --eof while 1-st loop
SELECT @strCode --IF WE ARE GENERATING MORE THAN 4000 CHARS 
SET @strCode = ''                  
set @strCode = @strCode + @WinNewLine+ @WinNewLine + @Tab + @Tab +  '#endregion FieldsAndProps ' + @WinNewLine + @WinNewLine
-- END GENERATION PROPERTIES 
 
 
-- START CONSTRUCTOR 
SET @CurrentDelimiterPositionVar = 1 --RESTART THE COUNTER
set @strCode = @strCode +  @WinNewLine + '#region Constructor' + @WinNewLine + @WinNewLine
set @strCode = @strCode + 'public ' + @TableName + '(System.Data.DataRow dr ) ' + @WinNewLine + '{'
 
 
WHILE @CurrentDelimiterPositionVar <= @Count --2nd loop        
BEGIN                                
--Load current value from the Table                                
SELECT @ColName = ColName FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar        
SELECT @DataType = DataType FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar               
SELECT @IS_NULLABLE = IS_NULLABLE FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar                    
SELECT @CHARACTER_MAXIMUM_LENGTH = CHARACTER_MAXIMUM_LENGTH FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar                    
 
IF @DataType = 'timestamp'        
begin 
SET @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1;                                
continue ; 
end 
 
 
 
-- get the C# type based on the passed sqlType, )( needs the DbVsCSharpTypes table ) 
set @CSharpDataType =( SELECT  dbo.funcGetCLRTypeBySqlType(@DataType) )
 
 
 
 
set @varPrivate = '_' + @ColName 
 
 
 
-- GENERATE THE START REGION PART 
SET @strCode = @strCode + @WinNewLine + @Tab+ @Tab + '#region ' + @ColName + @WinNewLine  + @WinNewLine
 
---- set the nullable 
--IF @IS_NULLABLE = 'YES'  and @Data <> 'string'      
--    SET @StrCode = @strCode +   'private ' + @CSharpDataType + '? ' +  @varPrivate + ' ;' + @WinNewLine 
--ELSE 
--    SET @StrCode = @strCode +   'private ' + @CSharpDataType + ' ' +  @varPrivate + ' ;' + @WinNewLine 
 
 
DECLARE @strConvertToCode nvarchar(200) 
set @strConvertToCode  =( SELECT  dbo.funcGetCLRConvertToCodeBySqlType(@DataType) )
 
 
-- THE DBNULL
--IF @IS_NULLABLE = 'YES'  and @DataType <> 'string'
--    BEGIN
SET @StrCode = @strCode + @Tab + @Tab + @Tab + 
'if (dr["' + @ColName + '"] != null && !(dr["' + @ColName + '"] is DBNull))
this.' + @ColName + ' = ' + @strConvertToCode  + '(dr["' + @ColName + '"]);' + @WinNewLine
 
--    END --EOF IF @IS_NULLABLE = 'YES'  and @DataType <> 'string'
--ELSE 
--    BEGIN
--    SET @StrCode = @strCode +   'public ' + @DataType +  ' ' + @ColName + @WinNewLine + '{' + @WinNewLine
--    END -- EOF ELSE IF @IS_NULLABLE = 'YES'  and @DataType <> 'string'
 
 
 
-- GENERATE THE END REGION PART FOR THE IF DR
SET @strCode = @strCode + @WinNewLine + @Tab+ @Tab + '#endregion ' + @ColName  + @WinNewLine + @WinNewLine
 
 
--??
--if @CurrentDelimiterPositionVar != @Count         
--SET @StrCode = @StrCode + ''        
 
--PRINT @StrCode         
--DEBUGGING        
--PRINT '@ColName - ' + @ColName         
--PRINT '@DataType - ' + @DataType                  
--PRINT '@IS_NULLABLE - ' + @IS_NULLABLE         
--PRINT '@CHARACTER_MAXIMUM_LENGTH - ' +  CONVERT ( VARCHAR , @CHARACTER_MAXIMUM_LENGTH )   
 
SELECT @strCode --IF WE ARE GENERATING MORE THAN 4000 CHARS 
set @strCode = ''
SET @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1;                                
END --eof while 1-st loop 
 
SET @strCode = ''
 
set @strCode = @strCode + @Tab + '} //eof const for'+ @TableName 
set @strCode = @strCode + @WinNewLine + @WinNewLine + @Tab + '#endregion Constructor' + @WinNewLine + @WinNewLine
-- END CONSTRUCTOR 
 
-- BEGIN PARAMETERLESS CONST
set @strCode = @strCode +  @WinNewLine + '#region Parameterless Constructor' + @WinNewLine + @WinNewLine
set @strCode = @strCode + 'public ' + @TableName + '() ' + @WinNewLine + '{'
-- NOTHING HAPPENS HERE
set @strCode = @strCode + @Tab + '} //eof Parameterless const for'+ @TableName 
set @strCode = @strCode + @WinNewLine + @WinNewLine + @Tab + '#endregion Parameterless Constructor' + @WinNewLine + @WinNewLine
-- END PARAMETERLESS CONST
 
 
 
 
 
set @strCode = + @strCode + @WinNewLine + ' } //eof class ' + @TableName + @WinNewLine
set @strCode = + @strCode + @WinNewLine + ' } //eof namespace  ' + @WinNewLine
 
 
SELECT @strCode 
END TRY        --end try                            
BEGIN CATCH                                  
print ' Error number: ' + CAST(ERROR_NUMBER() AS varchar(100)) +                         
'Error message: ' + ERROR_MESSAGE() + 'Error severity: ' +           
CAST(ERROR_SEVERITY() AS VARCHAR(9)) +                         
'Error state: ' + CAST(ERROR_STATE() AS varchar(100)) +           
'XACT_STATE: ' + CAST(XACT_STATE() AS varchar(100))                                  
END CATCH                                  
 
END --procedure end                                       
/* 
<doc> Generates a C# class base on DataType conversion</doc>
*/
GO                            
/*           
Example usage:         
exec procUtils_GenerateClass 'PageType'
*/

how-to generate C# classes with stored procedure in sql server 2008



/****** Object:  StoredProcedure [dbo].[procUtils_GenerateClass]    
Script Date: 03/20/2010 13:10:40 ******/
IF  EXISTS (SELECT * FROM sys.objects 
WHERE object_id = OBJECT_ID(N'[dbo].[procUtils_GenerateClass]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[procUtils_GenerateClass]
GO
 
/****** Object:  StoredProcedure [dbo].[procUtils_GenerateClass]    
 
Script Date: 03/20/2010 13:10:40 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
 
CREATE PROCEDURE [dbo].[procUtils_GenerateClass]
@TableName [varchar](50)
WITH EXECUTE AS CALLER
AS
BEGIN -- proc start                                      
SET NOCOUNT ON;                                      
 
DECLARE @DbName nvarchar(200 ) 
select @DbName = DB_NAME()               
declare @strCode nvarchar(max) 
set @strCode = ''
 
 
BEGIN TRY        --begin try                            
 
set @strCode = @strCode +  'namespace ' + @DbName + '.Gen  {' + CHAR(13)  
set @strCode = @strCode +  'public class ' + @TableName + CHAR(11) +  '{ ' + CHAR(13)  + CHAR(13)
--CODE SNIPPET TO LIST TABLE COLUMNS           
-- RUN IN SSMS WITH cTRL + t FIRST TO OUTPUT THE RESULT TO TEXT FOR COPY PASTE          
--FIRST SEARCH THE TABLE WHICH HAD A "Feature" in its name           
--SELECT NAME FROM SYS.TABLES WHERE NAME LIKE '%Feature%'          
--select column_name from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='Feature'              
DECLARE @ColNames TABLE                                
(                                
Number [int] IDENTITY(1,1), --Auto incrementing Identity column                              
ColName [varchar](300) , --The string value                        ,         
DataType varchar(50) ,  --the datatype                       
IS_NULLABLE nvarchar(5) , --should we add =null in front         
CHARACTER_MAXIMUM_LENGTH INT        
)                                
--Decalre a variable to remember the position of the current delimiter                                
DECLARE @CurrentDelimiterPositionVar INT                                 
DECLARE @PkColName varchar(200)      
set @PkColName = ''
declare @ColumnName varchar(200)  
--Decalre a variable to remember the number of rows in the table                                
DECLARE @Count INT                                
--Populate the TABLE variable using some logic                                
-- SELECT * from INFORMATION_SCHEMA.COLUMNS                             
 
--SET IDENTITY_INSERT ON ; 
INSERT INTO @ColNames         
SELECT column_name ,  Data_type , IS_NULLABLE , CHARACTER_MAXIMUM_LENGTH  
from INFORMATION_SCHEMA.COLUMNS                             
where TABLE_NAME=@TableName                                
--Initialize the looper variable                                
SET @CurrentDelimiterPositionVar = 1                                
--Determine the number of rows in the Table                                
SELECT @Count=max(Number) from @ColNames                                
--A variable to hold the currently selected value from the table                                
DECLARE @ColName varchar(300);                                
DECLARE @DataType varchar(50)                      
DECLARE @IS_NULLABLE VARCHAR(5)        
DECLARE @CHARACTER_MAXIMUM_LENGTH INT        
--Loop through until all row processing is done              
WHILE @CurrentDelimiterPositionVar <= @Count --1st loop        
BEGIN                                
--Load current value from the Table                                
SELECT @ColName = ColName FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar        
SELECT @DataType = DataType FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar               
SELECT @IS_NULLABLE = IS_NULLABLE FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar                    
SELECT @CHARACTER_MAXIMUM_LENGTH = CHARACTER_MAXIMUM_LENGTH FROM @ColNames         
WHERE Number = @CurrentDelimiterPositionVar                    
 
-- get the C# type based on the passed sqlType, )( needs the DbVsCSharpTypes table ) 
set @DataType =( SELECT  dbo.funcGetCLRTypeBySqlType(@DataType) )
 
IF @IS_NULLABLE = 'YES'        
set @DataType = @DataType + '?'
 
DECLARE @varPrivate nvarchar(200) 
set @varPrivate = '_' + @ColName 
 
 
 
-- GENERATE THE START REGION PART 
SET @strCode = @strCode + CHAR(11)+ CHAR(11) + '#region ' + @ColName + CHAR(13) + CHAR(13) 
 
--GENERATE THE PRIVATE MEMEBER 
SET @StrCode = @strCode +   'private ' + @DataType + ' ' +  @varPrivate + ' ;' + CHAR(13) 
 
-- GENERATE THE PUBLIC MEMBER 
SET @StrCode = @strCode +   'public ' + @DataType +  ' ' + @ColName + CHAR(13) + '{' + CHAR(13)
SET @StrCode = @strCode + CHAR(11) + CHAR(11) + 'get { return ' + @varPrivate + ' } ' 
SET @strCode = @strCode + CHAR(11) + CHAR(11) + 'set { ' + @varPrivate +' = value ; }' + CHAR(13) 
SET @strCode = @strCode + CHAR(11) + '} //eof prop ' + @ColName + CHAR(13) + CHAR(13)
 
-- GENERATE THE START REGION PART 
SET @strCode = @strCode + CHAR(11) + CHAR(11) + '#endregion ' + @ColName  + CHAR(13)
 
 
if @CurrentDelimiterPositionVar != @Count         
SET @StrCode = @StrCode + ''        
IF @DataType != 'timestamp'        
--PRINT @StrCode         
--DEBUGGING        
--PRINT '@ColName - ' + @ColName         
--PRINT '@DataType - ' + @DataType                  
--PRINT '@IS_NULLABLE - ' + @IS_NULLABLE         
--PRINT '@CHARACTER_MAXIMUM_LENGTH - ' +  CONVERT ( VARCHAR , @CHARACTER_MAXIMUM_LENGTH )   
 
set @strCode = @strCode + char(13)     
SET @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1;                                
END                               
 
set @strCode = + @strCode + char(13) + ' } //eof class ' + @TableName + CHAR(13)
set @strCode = + @strCode + char(13) + ' } //eof namespace  ' + CHAR(13)
SELECT @strCode 
END TRY        --end try                            
BEGIN CATCH                                  
print ' Error number: ' + CAST(ERROR_NUMBER() AS varchar(100)) +                         
'Error message: ' + ERROR_MESSAGE() + 'Error severity: ' +           
CAST(ERROR_SEVERITY() AS varCHAR(11)) +                         
'Error state: ' + CAST(ERROR_STATE() AS varchar(100)) +           
'XACT_STATE: ' + CAST(XACT_STATE() AS varchar(100))                                  
END CATCH                                  
END --procedure end                                       
/* 
<doc> Generates a C# class base on DataType conversion</doc>
*/
GO                            
/*           
Example usage:         
SELECT NAME FROM SYS.tables where name like '%feature%'          
EXEC [dbo].[procUtils_GenerateClass] @TableName = N'Requirement'         
*/

2010-03-26

SSMS + WIN7 SHORTCUTS

Alt + Tab --- switch windows in Win
Alt + D , Table -- go to to Search box , type the search file , Tabs to move to the actual file
CTRL+SHIFT+F -- output results to a separate file
Ctrl + E -- go to search box
Alt + W , arrows -- get the tab windows in SSMS
F5 -- execute the query
F6 -- jump between the query window and the results pane and back
CTRL + T -- Results to
CTRL + D --- Results to Grid –
CTRL + SHIFT + F --- Results to File


Source: SQL Server Management Studio Keyboard Shortcuts - SQL Server 2008 Books Online (November 2009)

2010-03-25

how-to track table DDL changes on sql server 2008



IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_MetaTable_IsDeleted]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[MetaTable] DROP CONSTRAINT [DF_MetaTable_IsDeleted]
END
 
GO
 
/****** Object:  Table [dbo].[MetaTable]    Script Date: 03/25/2010 15:44:59 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MetaTable]') AND type in (N'U'))
DROP TABLE [dbo].[MetaTable]
GO
 
/****** Object:  Table [dbo].[MetaTable]    Script Date: 03/25/2010 15:44:59 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
CREATE TABLE [dbo].[MetaTable](
[MetaTableId] [int] IDENTITY(1,1) NOT NULL,
[DbName] [varchar](256) NOT NULL,
[SchemaName] [varchar](256) NOT NULL,
[Name] [varchar](256) NOT NULL,
[Title] [varchar](200) NULL,
[DocumentationDescription] [varchar](2000) NOT NULL,
[IsPlatform] [bit] NULL,
[IsDeleted] [bit] NULL,
[CreationOrder] [int] NULL,
CONSTRAINT [PK_MetaTable] PRIMARY KEY CLUSTERED 
(
[MetaTableId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, 
ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
 
GO
 
ALTER TABLE [dbo].[MetaTable] ADD  CONSTRAINT [DF_MetaTable_IsDeleted]  DEFAULT ((0)) FOR [IsDeleted]
GO
 
 
/****** Object:  Table [dbo].[MetaTableHistory]    Script Date: 03/25/2010 15:49:43 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MetaTableHistory]') AND type in (N'U'))
DROP TABLE [dbo].[MetaTableHistory]
GO
 
/****** Object:  Table [dbo].[MetaTableHistory]    Script Date: 03/25/2010 15:49:43 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
CREATE TABLE [dbo].[MetaTableHistory](
[MetaTableHistoryId] [int] IDENTITY(1,1) NOT NULL,
[MetaTableId] [int] NOT NULL,
[DbName] [varchar](256) NOT NULL,
[SchemaName] [varchar](256) NOT NULL,
[Name] [varchar](256) NOT NULL,
[Title] [varchar](200) NULL,
[DocumentationDescription] [varchar](2000) NOT NULL,
[IsPlatform] [bit] NULL,
[IsDeleted] [bit] NULL,
[CreationOrder] [int] NULL,
[SqlLogin] [varchar](50) NOT NULL,
[Action] [varchar](50) NOT NULL,
[UpdatedWhen] [datetime] NOT NULL,
CONSTRAINT [PK_MetaTableHistory] PRIMARY KEY CLUSTERED 
(
[MetaTableHistoryId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, 
ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
 
GO
 
 
--use MyDb ; 
 
IF  EXISTS (SELECT * FROM sys.triggers 
WHERE parent_class_desc = 'DATABASE' AND name = N'trigDdl_UpdateTableDocumentation')
DISABLE TRIGGER [trigDdl_UpdateTableDocumentation] ON DATABASE
 
GO
 
/****** Object:  DdlTrigger [trigDdl_UpdateTableDocumentation]    Script Date: 03/25/2010 12:21:16 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE parent_class_desc = 'DATABASE' AND name = N'trigDdl_UpdateTableDocumentation')DROP TRIGGER [trigDdl_UpdateTableDocumentation] ON DATABASE
GO
 
/****** Object:  DdlTrigger [trigDdl_UpdateTableDocumentation]    Script Date: 03/25/2010 12:21:16 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
 
CREATE trigger [trigDdl_UpdateTableDocumentation]
on database
for CREATE_TABLE , DROP_TABLE
--, alter_TABLE, drop_TABLE
--, create_table, alter_table, drop_table,
--create_function, alter_function, drop_function
as
 
set nocount on
 
DECLARE  @data xml
DECLARE  @Event varchar(50)
DECLARE  @tableName varchar(256)
DECLARE  @DbName varchar(200)
DECLARE  @colName varchar (200) 
DECLARE  @DataType varchar(50)
DECLARE  @MaxLength int 
DECLARE  @IsNullable nvarchar(5)
DECLARE  @colMode varchar(10)
DECLARE  @eventType varchar(200)
DECLARE  @loginName varchar(200)
DECLARE  @eventName varchar(200)
DECLARE  @eventDate varchar(200)
DECLARE  @domainName varchar(200)
DECLARE  @SchemaName varchar(200)
DECLARE  @ordinalPosition int 
DECLARE  @colDefault varchar(200)
DECLARE @Documentation varchar(max) 
 
 
 
set @SchemaName = 'dbo'
set @domainName = 'trigMeta_UpdateTableColMetaData'
set @data = EVENTDATA()
set @tableName = cast (@data.value('(/EVENT_INSTANCE/ObjectName)[1]', 'varchar(256)') as varchar(256))
set @DbName = @data.value('(/EVENT_INSTANCE/DatabaseName)[1]', 'varchar(256)')
set @event = @data.value('(/EVENT_INSTANCE/EventType)[1]', 'varchar(50)')
set @eventType = @data.value('(/EVENT_INSTANCE/EventType)[1]', 'varchar(50)')
set @loginName = @data.value ('(/EVENT_INSTANCE/LoginName)[1]', 'varchar(256)') 
set @eventDate = getdate()
set @IsNullable = 'NO'
set @Documentation = convert(nvarchar(max) , @data.query('data(/EVENT_INSTANCE/TSQLCommand[1]/CommandText[1])'))
 
--REPLACE(string to search, string to find, string to replace)
--debug SELECT '1 DOCUMENTATION IS ' + @documentation
set @Documentation = replace ( convert(nvarchar(max) , @data ) , '&lt;' , '<')
--debug SELECT '2 DOCUMENTATION IS ' + @documentation
set @Documentation = replace ( convert(nvarchar(max) , @Documentation ) , '&gt;' , '>')
--repalce the enters 
set @Documentation = replace ( convert(nvarchar(max) , @Documentation ) , '&#x0D;' , char(13))
--now get a tmp variable 
declare @xmlData xml 
set @xmlData= convert(xml , @Documentation ) 
--debug SELECT '3 DOCUMENTATION IS ' + @documentation
set @Documentation = convert(nvarchar(max) , @xmldata.query('data(/EVENT_INSTANCE/TSQLCommand[1]/CommandText[1]/doc[1])' ))
 
 
 
 
 
DECLARE  @Type varchar(200)
DECLARE  @ObjectId int 
 
if @event = 'CREATE_TABLE' and @TableName <> 'MetaTable'
begin --if @event = 'CREATE_TABLE'
 
 
--WRITE HERE THE INSERT
--DEBUG SELECT 'DOCUMENTATION IS ' + @documentation
DECLARE @TableCount int 
set @TableCount  = ( select count([Name]) from MetaTable where Name=@TableName )
 
if @TableCount <> 1 
BEGIN 
INSERT INTO [dbo].[MetaTable] ( 
[DbName] ,  --type of varchar
[SchemaName] ,  --type of varchar
[Name],  --type of varchar
[Title],  --type of varchar
[DocumentationDescription]  --type of varchar
) 
VALUES 
( 
@DbName , --type of varchar
'dbo' , --type of varchar todo:change
@TableName , --type of varchar
@TableName , --type of varchar
@Documentation  --type of varchar
)            
end -- the table is not in the MetaTable table if ( @TableCount <> 1 ) 
else 
BEGIN
update MetaTable 
set [DocumentationDescription] = @Documentation
where [Name] = @TableName    
END --
 
 
end --if @event = 'CREATE_TABLE'
 
 
 
 
 
--if @event = 'ALTER_TABLE'
--begin -- if @event = 'alter_TABLE'
--SELECT  'alter table'
--SELECT  'Documentation -- ' + @Documentation
---- WRITE HERE THE UPDATE
--end -- if @event = 'ALTER_TABLE'
 
if @event = 'DROP_TABLE' AND @TableName <> 'MetaTable'
begin --if @event = 'DROP_Table'
--SELECT  'drop_table' 
--SELECT  'Documentation -- ' + @Documentation 
UPDATE METATABLE 
SET IsDeleted = convert(bit , 1) , 
[DocumentationDescription] = @Documentation
WHERE [NAME] = @TableName
--        Update [MetaTable] set IsDeleted = 'True' WHERE [ObjectId]=@ObjectId
end --if @event = 'DROP_Table'
 
GO
 
SET ANSI_NULLS OFF
GO
 
SET QUOTED_IDENTIFIER OFF
GO
 
DISABLE TRIGGER [trigDdl_UpdateTableDocumentation] ON DATABASE
GO
 
ENABLE TRIGGER [trigDdl_UpdateTableDocumentation] ON DATABASE
GO
 
 
/****** Object:  Trigger [trigGen_AfterDeleteOnMetaTable]    Script Date: 03/24/2010 08:03:26 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[trigGen_AfterDeleteOnMetaTable]'))
DROP TRIGGER [dbo].[trigGen_AfterDeleteOnMetaTable]
GO
 
/****** Object:  Trigger [dbo].[trigGen_AfterDeleteOnMetaTable]    Script Date: 03/24/2010 08:03:27 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
-- =============================================  
-- Author:  <Yordan Georgiev>  
-- Create date: <Create Date,,>  
-- Description: <Description,,>  
-- =============================================  
CREATE TRIGGER  [dbo].[trigGen_AfterDeleteOnMetaTable]   
ON  [dbo].[MetaTable]  
for Delete  
AS   
BEGIN  
-- SET NOCOUNT ON added to prevent extra result sets from  
-- interfering with SELECT statements.  
SET NOCOUNT ON;  
Insert into MetaTableHistory   
(   
[MetaTableId], --type of int
[DbName], --type of varchar
[SchemaName], --type of varchar
[Name], --type of varchar
[Title], --type of varchar
[DocumentationDescription], --type of varchar
[IsPlatform], --type of bit
[IsDeleted], --type of bit
[CreationOrder] , --type of int
[SqlLogin],  
[Action],  
[UpdatedWhen]  
)  
SELECT   
[MetaTableId], --type of int
[DbName], --type of varchar
[SchemaName], --type of varchar
[Name], --type of varchar
[Title], --type of varchar
[DocumentationDescription], --type of varchar
[IsPlatform], --type of bit
[IsDeleted], --type of bit
[CreationOrder] , --type of int
user_name(),  
'DELETE',  
getdate()
from Deleted  
END  
 
GO
 
 
/****** Object:  Trigger [trigGen_AfterInsertOnMetaTable]    Script Date: 03/24/2010 08:07:27 ******/
IF  EXISTS (SELECT * FROM sys.triggers 
WHERE object_id = OBJECT_ID(N'[dbo].[trigGen_AfterInsertOnMetaTable]'))
DROP TRIGGER [dbo].[trigGen_AfterInsertOnMetaTable]
GO
 
/****** Object:  Trigger [dbo].[trigGen_AfterInsertOnMetaTable]    Script Date: 03/24/2010 08:07:27 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
-- =============================================    
-- Author:  <Yordan Georgiev>    
-- Create date: <Create Date,,>    
-- Description: <Description,,>    
-- =============================================    
CREATE TRIGGER  [dbo].[trigGen_AfterInsertOnMetaTable]     
ON  [dbo].[MetaTable]    
for Insert    
AS     
BEGIN    
-- SET NOCOUNT ON added to prevent extra result sets from    
-- interfering with SELECT statements.    
SET NOCOUNT ON;    
Insert into MetaTableHistory     
(     
[MetaTableId], --type of int
[DbName], --type of varchar
[SchemaName], --type of varchar
[Name], --type of varchar
[Title], --type of varchar
[DocumentationDescription], --type of varchar
[IsPlatform], --type of bit
[IsDeleted], --type of bit
[CreationOrder] , --type of int
[SqlLogin],    
[Action],    
[UpdatedWhen]    
)    
SELECT     
[MetaTableId], --type of int
[DbName], --type of varchar
[SchemaName], --type of varchar
[Name], --type of varchar
[Title], --type of varchar
[DocumentationDescription], --type of varchar
[IsPlatform], --type of bit
[IsDeleted], --type of bit
[CreationOrder] , --type of int
user_name(),    
'INSERT',    
getdate()
from MetaTable where MetaTableId in (select MetaTableId from Inserted)  
END    
 
GO
 
 
--exec procUtils_GenerateTableHistorySql 'MetaTable'
/****** Object:  Trigger [trigGen_AfterUpdateOnMetaTable]    Script Date: 11/25/2009 10:35:45 ******/    
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[trigGen_AfterUpdateOnMetaTable]'))    
DROP TRIGGER [dbo].[trigGen_AfterUpdateOnMetaTable]    
GO    
/****** Object:  Trigger [dbo].[trigGen_AfterUpdateOnMetaTable]    Script Date: 11/25/2009 10:35:45 ******/    
SET ANSI_NULLS ON    
GO    
SET QUOTED_IDENTIFIER ON    
GO    
-- =============================================    
-- Author:  <Yordan Georgiev>    
-- Create date: <Create Date,,>    
-- Description: <Description,,>    
-- =============================================    
CREATE TRIGGER  [dbo].[trigGen_AfterUpdateOnMetaTable]     
ON  [dbo].[MetaTable]    
for Update    
AS     
BEGIN    
-- SET NOCOUNT ON added to prevent extra result sets from    
-- interfering with SELECT statements.    
SET NOCOUNT ON;    
Insert into MetaTableHistory     
(     
[MetaTableId], --type of int
[DbName], --type of varchar
[SchemaName], --type of varchar
[Name], --type of varchar
[Title], --type of varchar
[DocumentationDescription], --type of varchar
[IsPlatform], --type of bit
[IsDeleted], --type of bit
[CreationOrder] , --type of int
[SqlLogin],    
[Action],    
[UpdatedWhen]    
)    
SELECT     
[MetaTableId], --type of int
[DbName], --type of varchar
[SchemaName], --type of varchar
[Name], --type of varchar
[Title], --type of varchar
[DocumentationDescription], --type of varchar
[IsPlatform], --type of bit
[IsDeleted], --type of bit
[CreationOrder] , --type of int
user_name(),    
'UPDATE',    
getdate()
from MetaTable where MetaTableId in (select MetaTableId from Inserted)    
END    
GO    
--SELECT * FROM [dbo].[MetaTableHistory] ORDER BY 1 DESC 
--SELECT NAME FROM SYS.PROCEDURES WHERE NAME LIKE '%PROC%'
--SELECT NAME FROM SYS.TABLES WHERE NAME LIKE '%TABLE%'
--exec sp_HelpText procUtils_GenerateMetaInsert
--exec procUtils_GenerateMetaInsert 'TABLE'
 
-- FIRST REMOVE THE FOREIGN KEY CONSTRAINTS 
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MetaTableStatus_MetaTable]') AND parent_object_id = OBJECT_ID(N'[dbo].[MetaTableStatus]'))
ALTER TABLE [dbo].[MetaTableStatus] DROP CONSTRAINT [FK_MetaTableStatus_MetaTable]
GO
 
 
-- ADD HERE THE DROP TABLE STATEMENTS OF THE REFERENCES TABLES 
 
truncate table MetaTable 
 
 
 
 
SET IDENTITY_INSERT [dbo].[MetaTable] ON;
BEGIN TRANSACTION;
INSERT INTO [dbo].[MetaTable]([MetaTableId], [DbName], [SchemaName], [Name], [Title], [DocumentationDescription], [IsPlatform], [IsDeleted], [CreationOrder])
SELECT 1, N'MyDb', N'dbo', N'MetaTable', N'MetaTable', N'The table used to describe all other tables in the database', 1, 0, 1 UNION ALL
SELECT 2, N'MyDb', N'dbo', N'User1', N'User1 table', N'Contains all the user data ', 1, 0, 2 UNION ALL
SELECT 3, N'MyDb', N'dbo', N'NamingConvention', N'NamingConvention',N'Provides basic aggreed naming conventions patterns', 1, 0, 7 
COMMIT;
RAISERROR (N'[dbo].[MetaTable]: Insert Batch: 1.....Done!', 10, 1) WITH NOWAIT;
GO
 
SET IDENTITY_INSERT [dbo].[MetaTable] OFF;
 
 
--SELECT TOP 50 * FROM DdlLog ORDER BY 1 DESC
 
--select 'SELECT ' + convert(varchar(10), row_number() over (ORDER BY create_date )) + ', N''MyDb'', N''dbo'', N''' + name + ''', N''' + name + ''', N''' + name + ' - Description '', 1, 0, 10 UNION ALL '  from sys.tables  
 
 
-- AND THE CREATE TABLE STATEMENTS 
 
-- READDD THE FOREIGN KEYS

how-to find out whether or not a column is the primary key in a table on sql server 2008



-- GENERIC WAY OF FINDING OUT WHETHER A COLUMN IS THE PRIMARY KEY FOR A TABLE
-- IN SQL SERVER 2008
 
DECLARE @TableName nvarchar(200)
DECLARE @ColumnName nvarchar(200)
SELECT @TableName = 'Bug'
SELECT @ColumnName = 'BugId'
 
SELECT 
INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME AS TABLE_NAME  , 
INFORMATION_SCHEMA.KEY_COLUMN_USAGE.COLUMN_NAME AS COLUMN_NAME, 
REPLACE(INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_TYPE,' ', '_') AS CONSTRAINT_TYPE 
--INTO ##TMP
FROM 
INFORMATION_SCHEMA.TABLE_CONSTRAINTS 
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE ON 
INFORMATION_SCHEMA.TABLE_CONSTRAINTS.CONSTRAINT_NAME = 
INFORMATION_SCHEMA.KEY_COLUMN_USAGE.CONSTRAINT_NAME 
WHERE 
INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME <> N'sysdiagrams' 
AND INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME = @TableName 
AND INFORMATION_SCHEMA.KEY_COLUMN_USAGE.COLUMN_NAME = @ColumnName
ORDER BY 
INFORMATION_SCHEMA.TABLE_CONSTRAINTS.TABLE_NAME ASC
 
declare @IsPrimaryKey int 
select @IsPrimaryKey  = @@ROWCOUNT
IF @IsPrimaryKey  = 1 
SELECT 'The Column Name ' + @ColumnName + ' IS the Primary Key for the ' + @TableName + ' table '
ELSE 
SELECT 'The Column Name ' + @ColumnName + ' IS NOT the Primary Key for the ' + @TableName + ' table '
 
 

IPhone SUCKS !!!

As an IT guy most of my less IT prone people ask for IT related favors ...
Yesterday a good friend of mine wanted to install Skype on his Finnish IPhone ... His was largely disappointed after noticing that the use over 3G is restricted ... and it was a hard time for me trying to explain him about all the lock in of customers ... large plan paying ... big money interests etc. why it did not work ...

Than he ask about any "turnaround" ... and than it was again the big talk about the "cat and the mouses" , "the bricks and the hacks " ...

And guess what he was still 100% happy and confident about his IPhone against my N900 with the integrated Skype and GoogleTalk and possibilities for whatever future Internet based UC ...


Ok. So what the lesson here. Marketing rules. It is all about the Customer perception and feelings and not about any metrics, "real facts" etc.

So .. my personal perception is :
IPHONE IS COOL , BUT ....


IT SUCKS !!!

how-to obtain DNS server address automatically via the command line



::how - to enable dynamic dhcp on Win7 via the command line
:: A furter readings and  SOURCE
::tested on Windows 7, should have the same or a similar syntax for other Win OS's

netsh interface ipv4 set address name="Wireless Network Connection" source=dhcp

2010-03-23

how-to execute all the sql files in the current directory via cmd and sqlcmd and output the errors in a log file



for /f %i  in ('dir *.SQL /s /b /o') DO ECHO   %DATE% --- %TIME% RUNNING  %i 1>>"..\install.log"&SQLCMD -U sqlloginUserName -P SecretPass -H hostname -d cas_dev -t 30 -w 80 -u -p 1 -b -i %i  -r1 1>> "..\install.log" 2>> "..\error.log" 

2010-03-22

how-to populate the fk pk relations table



/*
-- BEGIN DOC 
This script populates all the foreign keys relationships into a an existing meta table 
-- END DOC 
*/
TRUNCATE TABLE MetaPkFkRelations 
INSERT INTO MetaPkFkRelations ( 
[FkTable],[FkName],[FkColName],[PkTable],[PKColName]) 
SELECT OBJECT_NAME(f.parent_object_id) AS 'FkTable' , 
f.name AS 'FkName' , 
COL_NAME(fc.parent_object_id,fc.parent_column_id) AS 'FkColName' , 
OBJECT_NAME (f.referenced_object_id) as 'PkTable' , COL_NAME(fc.referenced_object_id,
fc.referenced_column_id) AS 'PKColName'
--into MetaPkFkRelations
FROM .sys.foreign_keys AS f
INNER JOIN .sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id

how-to create a table for storing FK and PK relations



/****** Object:  Table [dbo].[MetaPkFkRelations]    Script Date: 03/22/2010 16:24:44 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MetaPkFkRelations]') AND type in (N'U'))
DROP TABLE [dbo].[MetaPkFkRelations]
GO
 
/****** Object:  Table [dbo].[MetaPkFkRelations]    Script Date: 03/22/2010 16:24:44 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
CREATE TABLE [dbo].[MetaPkFkRelations](
[MetaPkFkRelationsId] [int] IDENTITY(1,1) NOT NULL,
[FkTable] [nvarchar](128) NULL,
[FkName] [sysname] NOT NULL,
[FkColName] [nvarchar](128) NULL,
[PkTable] [nvarchar](128) NULL,
[PKColName] [nvarchar](128) NULL,
[OnDeleteCascate] [bit] NULL,
[OnDeleteUpdate] [bit] NULL
) ON [PRIMARY]
 
GO
 
 

how-to create a meta table for storing foreign keys info ...



drop table MetaPkFkRelations
 
SELECT OBJECT_NAME(f.parent_object_id) AS 'FkTable' , 
f.name AS 'FkName' , 
COL_NAME(fc.parent_object_id,fc.parent_column_id) AS 'FkColName' , 
OBJECT_NAME (f.referenced_object_id) as 'PkTable' , COL_NAME(fc.referenced_object_id,
fc.referenced_column_id) AS 'PKColName'
into MetaPkFkRelations
FROM .sys.foreign_keys AS f
INNER JOIN .sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id
 
--select * from MetaPkFkRelations
--exec procUtils_ListCols 'MetaPkFkRelations'
SELECT 'ALTER TABLE [' + [FkTable]+ '] ADD CONSTRAINT FK_' + [FkTable]+ '_' + [FkColName] + '_' + 
PkTable + '_' + PkColName + ' FOREIGN KEY(' + FkColName + ')REFERENCES [' + PkTable +'](' + PkColName + ')' from MetaPkFkRelations
 
SELECT 'ALTER TABLE [' + FkTable + '] DROP  CONSTRAINT FK_' + [FkTable]+ '_' + [FkColName] + '_' + 
PkTable + '_' + PkColName from MetaPkFkRelations
 
 
 
--ALTER TABLE [UserRole] ADD CONSTRAINT FK_UserRole_UserRoleId_UserRole_UserRoleId FOREIGN KEY(UserRoleId)REFERENCES [UserRole](UserRoleId)
--ALTER TABLE [Bug] ADD CONSTRAINT FK_Bug_AssignedTo_User_UserId FOREIGN KEY(AssignedTo)REFERENCES [User](UserId)
--ALTER TABLE [Bug] ADD CONSTRAINT FK_Bug_DetectedBy_User_UserId FOREIGN KEY(DetectedBy)REFERENCES [User](UserId)
 
--ALTER TABLE [UserRole] DROP  CONSTRAINT FK_UserRole_UserRoleId_UserRole_UserRoleId
--ALTER TABLE [Bug] DROP  CONSTRAINT FK_Bug_AssignedTo_User_UserId
--ALTER TABLE [Bug] DROP  CONSTRAINT FK_Bug_DetectedBy_User_UserId

how-to recreate a table with existing foreign keys



-- DROP THE FOREIGN KEYS 
SELECT 'ALTER TABLE ' + OBJECT_NAME(f.parent_object_id)+
' DROP  CONSTRAINT ' + f.name 
FROM .sys.foreign_keys AS f
INNER JOIN .sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id
 
--ADD HERE THE DROP TABLE STATEMENTS OF THE REFERENCES TABLES 
-- AND THE CREATE TABLE STATEMENTS 
 
-- ADD THE FOREIGN KEYS AGAIN 
SELECT 'ALTER TABLE ' + OBJECT_NAME(f.parent_object_id)+
' ADD CONSTRAINT ' + f.name + ' FOREIGN KEY'+'('+COL_NAME(fc.parent_object_id,fc.parent_column_id)+')'
+'REFERENCES ['+OBJECT_NAME (f.referenced_object_id)+']('+COL_NAME(fc.referenced_object_id,
fc.referenced_column_id)+')' as Scripts
FROM .sys.foreign_keys AS f
INNER JOIN .sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id

how-to get the size of all ms sql databases

Courtesy of Sans SQL


EXEC sp_msforeachdb 'Use ?
 
Declare @dbsize float
Declare @logsize float
select @dbsize = sum(convert(bigint,case when status & 64 = 0 then size else 0 end)) 
, @logsize = sum(convert(bigint,case when status & 64 <> 0 then size else 0 end)) 
from dbo.sysfiles 
select  ltrim(str((convert (dec (15,2),@dbsize) + convert (dec (15,2),@logsize)) 
* 8192 / 1048576,15,2) + '' MB'') AS [Size of ?]'

How-to generate Insert statement procedures on sql server



/****** Object:  StoredProcedure [dbo].[procUtils_GenerateInsertProc]    Script Date: 03/20/2010 13:06:13 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[procUtils_GenerateInsertProc]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[procUtils_GenerateInsertProc]
GO
 
/****** Object:  StoredProcedure [dbo].[procUtils_GenerateInsertProc]    Script Date: 03/20/2010 13:06:13 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
--exec procUtils_GenerateInsertProc 'Whatever'  
--exec sp_HelpText procUtils_GenerateInsertProc   
CREATE PROCEDURE [dbo].[procUtils_GenerateInsertProc]        
@TableName [varchar](50)        
WITH EXECUTE AS CALLER        
AS        
BEGIN -- proc start                                                            
SET NOCOUNT ON;                                                            
BEGIN TRY        --begin try                                                  
--FIRST SEARCH THE TABLE WHICH HAD A "Feature" in its name                                 
--SELECT NAME FROM SYS.TABLES WHERE NAME LIKE '%Feature%'                                
--SELECT column_name from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='Feature'              --SELECT *     from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='Task'                          
 
--Decalre a variable to remember the position of the current delimiter                           
DECLARE @ProcName varchar(1000)             
set @ProcName = '[dbo].[procGen_' + @TableName + '_Insert]'            
 
DECLARE @CurrentDelimiterPositionVar INT                                     
DECLARE @PkColumnName varchar(200)          
--Decalre a variable to remember the number of rows in the table                                 
DECLARE @Count INT                                    
DECLARE @ColumnName varchar(300);                                    
DECLARE @DataType varchar(50)                          
DECLARE @IsNullable bit    
DECLARE @MaxLength INT            
DECLARE @IsComputed BIT
set @IsComputed = 0     
DECLARE @IsPrimaryKey BIT
set @IsPrimaryKey = 0     
DECLARE @CODESTR VARCHAR(max)             
--PRINT DROP PROCEDURE    
set @CODESTR = ' ' 
 
--Declare the Table variable                                     
DECLARE @ColumnNames TABLE                                    
(                                    
Number INT IDENTITY(1,1), --Auto incrementing Identity column    
TableName varchar(300) , --the name of the table    
ColumnName VARCHAR(300) , --The string value                        ,             
DataType varchar(50) ,  --the datatype                           
IsNullable bit , --should we add =null in front             
MaxLength INT        , --VARCHAR(LENGHTi)    
IsComputed bit ,  --whether or not this table is computed    
IsPrimaryKey bit --whether or not this table is computed    
)                                    
--Populate the TABLE variable using some logic                                    
-- SELECT * from INFORMATION_SCHEMA.COLUMNS                                 
INSERT INTO @ColumnNames             
(  
TableName ,   
ColumnName ,   
DataType ,   
IsNullable ,   
MaxLength ,           
IsComputed , 
IsPrimaryKey )  
SELECT   
TableName ,   
ColumnName ,   
DataType ,  
IsNullable ,   
MaxLength ,   
IsComputed   , 
IsPrimaryKey
from viewMeta_TableColumns   
--debug where TableName = 'Whatever'  
where TableName = @TableName  
--SELECT column_name ,  Data_type , IsNullable , MaxLength            
--from INFORMATION_SCHEMA.COLUMNS                                 
--where TABLE_NAME=@TableName                                    
--Initialize the looper variable                                    
SET @CurrentDelimiterPositionVar = 1                                    
--Determine the number of rows in the Table                                    
SELECT @Count=max(Number) from @ColumnNames                                    
--A variable to hold the currently selected value from the table                                    
set @CODESTR = @CODESTR +  'IF OBJECT_ID(''' + @ProcName + ''') IS NOT NULL            
BEGIN             
DROP PROC ' + @ProcName + '             
END             
GO'            
set @CODESTR = @CODESTR + '                          
/****** Object:  StoredProcedure ' + @ProcName + '*/            
SET ANSI_NULLS ON            
GO            
SET QUOTED_IDENTIFIER ON            
GO            
CREATE PROCEDURE ' + @ProcName + '            
@CurUserSessionId [int] ,            
@CurPageTypeId [int] ,            
@MsgOut [varchar](200) OUTPUT ,            
@DebugMsgOut [varchar](200) OUTPUT,            
@Ret [int] OUTPUT ,' + CHAR(13)            
--@COLUMN_NAME [DATA_TYPE] (MAX_LENGTH) =NULL ,             
WHILE @CurrentDelimiterPositionVar <= @Count --1st loop         
BEGIN                                    
 
--Load current value from the Table                                    
SELECT @ColumnName = ColumnName FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar            
SELECT @DataType = DataType FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar                   
SELECT @MaxLength = MaxLength FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar                        
set @IsNullable = ( select  IsNullable FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar  )
set @IsPrimaryKey = ( select IsPrimaryKey FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar                        )
 
 
if ( @DataType = 'timestamp' or @IsComputed = 1) 
begin 
set @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1
continue    
end 
set @CODESTR = @CODESTR + '@' + @ColumnName + ' ['+ @DataType +  '] '            
--ADD THE (200)            
IF @MaxLength IS NOT NULL             
BEGIN --IF @MaxLength IS NOT NULL             
--xml            
if @DataType <> 'xml' and @DataType <> 'sql_variant' and 
@DataType <> 'text' and @DataType <> 'ntext' and @DataType <> 'image' and 
@DataType <> 'hierarchyid' and @DataType <> 'bit' and @DataType <> 'varbinary'  and
@DataType <> 'int' and @DataType <> 'uniqueidentifier' and @DataType <> 'tinyint' and 
@DataType <> 'timestamp' and @DataType <> 'uniqueidentifier' and @DataType <> 'smallint' and 
@DataType <> 'bigint' and @DataType <> 'smallmoney' and @DataType <> 'money' and 
@DataType <> 'real' and @DataType <> 'smalldatetime' and @DataType <> 'datetime' 
 
 
begin --those with()            
 
if @MaxLength <> -1          
SET @CODESTR = @CODESTR + '(' + CONVERT(VARCHAR , @MaxLength ) + ')'               
else           
SET @CODESTR =    @CODESTR + '(max)'               
end --those with(200)            
else             
begin             
SET @CODESTR =  @CODESTR             --DO NOTHING
end               
END --IF @MaxLength IS NOT NULL             
 
IF @IsNullable = 1            
SET @CODESTR = + @CODESTR + ' = NULL '            
 
if @IsPrimaryKey = 1           
SET @CODESTR = @CODESTR + ' OUTPUT '           
 
if @CurrentDelimiterPositionVar <> @Count             
SET @CODESTR = @CODESTR + ','            
 
--DEBUGGING            
--set @CODESTR = @CODESTR + '@ColumnName - ' + @ColumnName             
--set @CODESTR = @CODESTR + '@DataType - ' + @DataType                      
--set @CODESTR = @CODESTR + '@IsNullable - ' + @IsNullable             
--set @CODESTR = @CODESTR + '@MaxLength - ' +  CONVERT ( VARCHAR , @MaxLength )            
set @CODESTR = @CODESTR + CHAR(13)
 
SET @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1       
END                                   
SET @CODESTR = @CODESTR + '          
WITH EXECUTE AS CALLER              
AS              
BEGIN -- proc start                                          
SET NOCOUNT ON;                                          
BEGIN TRY        --begin try                                   
--                
set @Ret = 1 --assume false from the beginning                 
declare @MsgKey [nvarchar](max)      
declare @MsgTxt [nvarchar](max)         
exec procUtils_GetMsgTxtByKeyAndUserSessionId      
@UserSessionId =2 ,       
@MsgKey = ''MsgOkTheAddingOfItemIsOk'' ,       
@MsgTxt =  ''''      
set @MsgOut = replace (@MsgTxt , ''{0}'' , ''' + @TableName + '''  )      
declare @thisProcName varchar(300)                
set @thisProcName= ( SELECT OBJECT_NAME(@@PROCID))                        
'          
SET @CurrentDelimiterPositionVar = 1              --START LOOP AGAIN             
set @CODESTR = @CODESTR +  '      
--Action !!!      
INSERT INTO [dbo].[' + @TableName + ']( ' + CHAR(13)                                    
--Loop through until all row processing is done                                    
WHILE @CurrentDelimiterPositionVar <= @Count     --2nd loop            
BEGIN                                    
 
--Load current value from the Table                                    
SELECT @ColumnName = ColumnName FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar            
SELECT @DataType = DataType FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar                   
SELECT @MaxLength = MaxLength FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar                        
set @IsNullable = ( select  IsNullable FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar  )
set @IsPrimaryKey = ( select IsPrimaryKey FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar                        )
 
 
if   @IsPrimaryKey = 1          
begin -- the primary key           
set @PkColumnName = @ColumnName          
end --the primary key           
 
if ( @DataType = 'timestamp' or @IsComputed = 1 or @IsPrimaryKey = 1 ) 
begin 
set @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1
continue    
end 
 
 
--select 
if @CurrentDelimiterPositionVar <= @Count  
BEGIN
set @CODESTR = @CODESTR + '[' + @ColumnName + ']' --null the codestring var            
if @CurrentDelimiterPositionVar <> @Count  
set @CODESTR = @CODESTR + ',  --type of ' + @DataType   + CHAR(13) --WITH COMMA
ELSE 
set @CODESTR = @CODESTR + ' --type of ' + @DataType   + CHAR(13) --NO COMMA
END -- IF SHOULD PRINT COLUMN 
 
SET @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1;                             
 
END --eof while 2
set @CODESTR = @CODESTR +  ') VALUES ( '
--AND START ALL OVER AGAIN                               
SET @CurrentDelimiterPositionVar = 1                          
--Loop through until all row processing is done                    
 
WHILE @CurrentDelimiterPositionVar <= @Count --WHILE 3            
BEGIN                                    
 
--Load current value from the Table                                    
SELECT @ColumnName = ColumnName FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar            
SELECT @DataType = DataType FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar                   
SELECT @MaxLength = MaxLength FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar                        
set @IsNullable = ( select  IsNullable FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar  )
set @IsPrimaryKey = ( select IsPrimaryKey FROM @ColumnNames             
WHERE Number = @CurrentDelimiterPositionVar                        )
 
if ( @DataType = 'timestamp' or @IsComputed = 1 or @IsPrimaryKey = 1) 
begin 
set @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1
continue    
end 
 
set @CODESTR = @CODESTR + '@' + @ColumnName 
 
if @CurrentDelimiterPositionVar <= @Count     
BEGIN
 
IF @CurrentDelimiterPositionVar <> @Count  
set @CODESTR = @CODESTR + ' , --type of ' + @DataType  --all others with comma
else
set @CODESTR = @CODESTR + ' --type of ' + @DataType  --the last one without comma
 
END -- IF SHOULD NOT PRINT COLUMN 
--increase the counter 
set @CODESTR = @CODESTR + CHAR(13)
SET @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1;                                    
END                                                           
set nocount off                                 
SET @CODESTR = @CODESTR +  ')            
SET @' + @pkColumnName + ' = @@IDENTITY          
set @Ret = @@ERROR                
set @DebugMsgOut = ''TODO:REMOVE INSERT OK ''              
END TRY                 
BEGIN CATCH                                        
EXEC @ret = [dbo].[procUtils_GetMsgTxtByKeyAndUserSessionId]                
@UserSessionId = 2,                
@MsgKey = N''ErrorMsgMenuRetrievalFailed'',                
@MsgTxt = @MsgOut OUTPUT                
set @ret = 1                                  
set @msgOut = @MsgTxt      
set @debugMsgOut = '' Error number: '' + CAST(ERROR_NUMBER() AS varchar(100)) +                               
''Error message: '' + ERROR_MESSAGE() + ''Error severity: '' +                 
CAST(ERROR_SEVERITY() AS varchar(10)) +                               
''Error state: '' + CAST(ERROR_STATE() AS varchar(100)) +                 
''XACT_STATE: '' + CAST(XACT_STATE() AS varchar(100))                                        
-- record the error in the database                                        
set @debugMsgOut = @debugMsgOut + @msgOut                            
INSERT INTO [dbo].[LogStore] ( [Date],[Thread],[Level],[Logger],[Message])                
values ( getdate() , N''8'', N''DEBUG'', @thisProcName , @debugMsgOut )                
END CATCH                                        
END --procedure end               
GO             
'                          
print @codestr
 
END TRY        --end try                                                  
BEGIN CATCH                                                        
print ' Error number: ' + CAST(ERROR_NUMBER() AS varchar(100)) +                                               
'Error message: ' + ERROR_MESSAGE() + 'Error severity: ' +                                 
CAST(ERROR_SEVERITY() AS varchar(1000)) +                                
'Error state: ' + CAST(ERROR_STATE() AS varchar(100)) +                                 
'XACT_STATE: ' + CAST(XACT_STATE() AS varchar(100))                                                        
END CATCH                                                        
END --procedure end                                                             
--USE [Gaf]                                
--GO                                
--SELECT NAME FROM SYS.tables where name like '%Msg%'                                
--EXEC [dbo].[procUtils_GenerateInsertProc] @TableName = N'Whatever'
 
GO
 
 

Labels

perl (41) Cheat Sheet (25) how-to (24) windows (14) sql server 2008 (13) linux (12) oracle (12) sql (12) Unix (11) cmd windows batch (10) mssql (10) cmd (9) script (9) textpad (9) netezza (8) sql server 2005 (8) cygwin (7) meta data mssql (7) metadata (7) bash (6) code generation (6) Informatica (5) cheatsheet (5) energy (5) tsql (5) utilities (5) excel (4) future (4) generic (4) git cheat sheet (4) html (4) perl modules (4) programs (4) settings (4) sh (4) shortcuts (4) поуки (4) принципи (4) Focus Fusion (3) Solaris (3) cool programs (3) development (3) economy (3) example (3) freeware (3) fusion (3) logging (3) morphus (3) mssql 2005 (3) nuclear (3) nz (3) parse (3) python (3) sftp (3) sofware development (3) source (3) sqlplus (3) table (3) vim (3) .Net (2) C# (2) China (2) GUI (2) Google (2) GoogleCL (2) Solaris Unix (2) architecture (2) ascii (2) awk (2) batch (2) cas (2) chrome extensions (2) code2html (2) columns (2) configuration (2) conversion (2) duplicates (2) excel shortcuts (2) export (2) file (2) free programs (2) informatica sql repository (2) linux cheat sheet (2) mssql 2008 (2) mysql (2) next big future (2) nsis (2) nz netezza cheat sheet (2) nzsql (2) ora (2) prediction (2) publish (2) release management (2) report (2) security (2) single-click (2) sqlserver 2005 (2) sqlserver 2008 (2) src (2) ssh (2) template (2) tools (2) vba (2) video (2) xlt (2) xml (2) youtube videos (2) *nix (1) .vimrc (1) .virmrc vim settings configs (1) BSD license (1) Bulgaria (1) Dallas (1) Database role (1) Dense plasma focus (1) Deployment (1) ERP (1) ExcelToHtml (1) GD (1) GDP (1) HP-UX (1) Hosting (1) IDEA (1) INC (1) IT general (1) ITIL management bullshit-management (1) IZarc (1) Java Web Start (1) JavaScript anchor html jquery (1) Khan Academy (1) LINUX UNIX BASH AND CYGWIN TIPS AND TRICKS (1) Linux Unix rpm cpio build install configure (1) Linux git source build .configure make (1) ListBox (1) MIT HYDROGEN VIRUS (1) OO (1) Obama (1) PowerShell (1) Run-time (1) SDL (1) SIWA (1) SOX (1) Scala (1) Services (1) Stacks (1) SubSonic (1) TED (1) abstractions (1) ansible hosts linux bash (1) ansible linux deployment how-to (1) ansible yum pip python (1) apache (1) apache 2.2 (1) application life cycle (1) architecture input output (1) archive (1) arguments (1) avatar (1) aws cheat sheet cli (1) aws cli (1) aws cli amazon cheat sheet (1) aws elb (1) backup (1) bash Linux open-ssh ssh ssh_server ssh_client public-private key authentication (1) bash perl search and replace (1) bash stub (1) bin (1) biofuels (1) biology (1) books (1) browser (1) bubblesort (1) bugs (1) build (1) byte (1) cas_sql_dev (1) chennai (1) chrome (1) class (1) claut (1) cmdow (1) code generation sqlserver (1) command (1) command line (1) conf (1) confluence (1) console (1) convert (1) cool programs windows free freeware (1) copy paste (1) copy-paste (1) csv (1) ctags (1) current local time (1) cygwin X11 port-forwarding mintty xclock Linux Unix X (1) cygwin bash how-to tips_n_tricks (1) cygwin conf how-to (1) data (1) data types (1) db2 cheat sheet (1) db2 starter ibm bash Linux (1) debt (1) diagram (1) dictionaries (1) digital (1) disk (1) disk space (1) documentation (1) dos (1) dubai (1) e-cars (1) electric cars (1) electricity (1) emulate (1) errors (1) exponents (1) export workflow (1) extract (1) fast export (1) fexp (1) file extension (1) file permissions (1) findtag (1) firewall (1) for loop (1) freaky (1) functions (1) fusion research (1) german (1) git gitlab issues handling system (1) google cli (1) google code (1) google command line interface (1) gpg (1) ha (1) head (1) helsinki (1) history (1) hop or flop (1) host-independant (1) how-to Windows cmd time date datetime (1) ibm db2 cognos installation example db deployment provisioning (1) ideas (1) image (1) informatica oracle sql (1) informatica repo sql workflows sessions file source dir (1) informatica source files etl (1) install (1) isg-pub issue-tracker architecture (1) it management best practices (1) java (1) jump to (1) keyboard shortcuts (1) ksh (1) level (1) linkedin (1) linux bash ansible hosts (1) linux bash commands (1) linux bash how-to shell expansion (1) linux bash shell grep xargs (1) linux bash tips and t ricks (1) linux bash unix cygwin cheatsheet (1) linux bash user accounts password (1) linux bash xargs space (1) linux cheat-sheet (1) linux cheatsheet cheat-sheet revised how-to (1) linux how-to non-root vim (1) linux ssh hosts parallel subshell bash oneliner (1) london (1) make (1) me (1) metacolumn (1) metadata functions (1) metaphonre (1) method (1) model (1) movie (1) multithreaded (1) mysql cheat sheet (1) mysql how-to table datatypes (1) n900 (1) nano (1) neteza (1) netezza bash linux nps (1) netezza nps (1) netezza nps nzsql (1) netezza nz Linux bash (1) netezza nz bash linux (1) netezza nz nzsql sql (1) netezza nzsql database db sizes (1) non-password (1) nord pol (1) nps backup nzsql schema (1) number formatting (1) nz db size (1) nz table count rows (1) nzsql date timestamp compare bigint to_date to_char now (1) on-lier (1) one-liners (1) one-to-many (1) oneliners (1) open (1) open source (1) openrowset (1) openssl (1) oracle PL/SQL (1) oracle Perl perl (1) oracle installation usability (1) oracle number formatting format-model ora-sql oracle (1) oracle templates create table (1) oracle trigger generic autoincrement (1) oracle vbox virtual box cheat sheet (1) oracle virtual box cheat sheet (1) outlook (1) parser (1) password (1) paths (1) perl @INC compile-time run-time (1) perl disk usage administration Linux Unix (1) perl modules configuration management (1) permissions (1) php (1) picasa (1) platform (1) postgreSQL how-to (1) powerShell cmd cygwin mintty.exe terminal (1) ppm (1) predictions (1) prices (1) principles (1) productivity (1) project (1) prompt (1) proxy account (1) public private key (1) publishing (1) putty (1) qt (1) read file (1) registry (1) relationship (1) repository (1) rm (1) scala ScalaFmt (1) scp (1) scripts (1) scsi (1) search and replace (1) sed (1) sendEmail (1) sh stub (1) shortcuts Windows sql developer Oracle (1) sidebar (1) silicon (1) smells (1) smtp (1) software development (1) software procurement (1) sofware (1) sort (1) sql script (1) sql_dev (1) sqlcmd (1) sqlite (1) sqlite3 (1) sshd (1) sshd cygwin (1) stackoverflow (1) stored procedure (1) stub (1) stupidity (1) subroutines (1) svn (1) sysinternals (1) system design (1) tail (1) tar (1) temp table (1) templates (1) teradata (1) terminal (1) test (1) testing (1) theory (1) thorium (1) time (1) tip (1) title (1) tmux .tmux.conf configuration (1) tmux efficiency bash (1) tool (1) ui code prototyping tips and tricks (1) umask Linux Unix bash file permissions chmod (1) url (1) urls (1) user (1) utility (1) utils (1) vb (1) vbox virtual box cheat sheet (1) vim perl regex bash search for string (1) vim recursively hacks (1) vim starter (1) vim-cheat-sheet vim cheat-sheet (1) vimeo (1) visual stuio (1) warsaw (1) wiki (1) wikipedia (1) window (1) windows 7 (1) windows 8 (1) windows programs (1) windows reinstall (1) windows utility batch perl space Windows::Clipboard (1) wisdoms (1) workflow (1) worth-reading (1) wrapper (1) xp_cmdshell (1) xslt (1) youtube (1)

Blog Archive

Translate with Google Translate

My Blog List