Friday, January 11, 2013

Infragistics installation on Windows Server 2008 64-Bit


   Infragistics installation on Windows Server 2008 64-Bit

One of my friend facing issues to installed the Infragistics in 64 bit server.

Error Description - While installing Infrajistics Software (Net Advantage TM   2006 Vol. 1 CLR 1.0 and 2.0) on Windows Server 2008 on 64-Bit OS – it completes installation upto 99% and then Rolls back the installation.

Resolutions- During installing Infrajistics Software (Net Advantage TM   2006 Vol. 1 CLR 1.0 and 2.0) on Windows Server 2008 on 64-Bit OS – set the following two things
1.                   Set the compatibility as Windows Server 2003 SP3 or Windows Server 2003 SP2 or Windows Server 2003 SP1 or Windows Server 2003 or Windows Server 2000 SP(x) or Windows Server 2000 - in the properties window of Setup File (NetAdvantage61CLR1x.exe and NetAdvantage61CLR20.exe)
2.                   During installing do not install complete software – use “Select Features” to install option and in the selection list – Remove (de-Select) the option of “ASP.NET samples”. This shall install the Infrajistics Software successfully on the machine (having OS as Windows  Server 2008 and type as 64-Bits).

 

Issues in Https File Downloading

Some times we are facing issues to download the file in HTTPS://www.site.com.
because in IE  https treats files downloading as junk. so it restricted.


Resolution: Removed the code which was sending “no-cache” headers to the browser. The code removed from the page load event -
               //Response.CacheControl = "no-cache";
               //Response.Expires = -1;

Wednesday, January 9, 2013

Generate Create Script for Tables

Generates the Create table script  for predefined tables. we can add the table name to the temp table.
as



drop table #AS 
create table #AS 
(tablename  varchar(100) not null,
tableScript  nvarchar(max) not null default ''
)
insert into #AS(tablename)  
SELECT 'REQREC_SPECIALIZATIONMST '
Union SELECT 'ERP_STATE  '
Union SELECT 'SUBCASTE '
declare @table varchar(100)
--set @table = 'REQREC_SUBCASTE' -- set table name here
declare @sql table(s varchar(1000), id int identity)
declare L1 cursor Forward_only
FOR 
select tablename from  #AS  
 OPEN L1
 FETCH NEXT FROM L1 INTO @table

 while @@FETCH_STATUS=0
 begin
-- create statement
delete  from @sql
insert into  @sql(s) values ('if not exists
(select * from sys.objects where OBJECT_ID=object_id(N'''+@table+'''))
begin create table [' + @table + '] (')

-- column list

insert into @sql(s)
select 
    '  ['+column_name+'] ' + 
    data_type + coalesce('('+cast(character_maximum_length as varchar)+')','') + ' ' +
    case when exists ( 
        select id from syscolumns
        where object_name(id)=@table
        and name=column_name
        and columnproperty(id,name,'IsIdentity') = 1 
    ) then
        'IDENTITY(' + 
        cast(ident_seed(@table) as varchar) + ',' + 
        cast(ident_incr(@table) as varchar) + ')'
    else ''
    end + ' ' +
    ( case when IS_NULLABLE = 'No' then 'NOT ' else '' end ) + 'NULL ' + 
    coalesce('DEFAULT '+COLUMN_DEFAULT,'') + ','

 from information_schema.columns where table_name = @table
 order by ordinal_position

-- primary key
declare @pkname varchar(100)
select @pkname = constraint_name from information_schema.table_constraints
where table_name = @table and constraint_type='PRIMARY KEY'

if ( @pkname is not null ) begin
    insert into @sql(s) values('  PRIMARY KEY (')
    insert into @sql(s)
    select '   ['+COLUMN_NAME+'],' from information_schema.key_column_usage
    where constraint_name = @pkname
    order by ordinal_position
    -- remove trailing comma
    update @sql set s=left(s,len(s)-1) where id=@@identity
    insert into @sql(s) values ('  )')
end
else begin
    -- remove trailing comma
    update @sql set s=left(s,len(s)-1) where id=@@identity
end

-- closing bracket
insert into @sql(s) values( ')'+' END' )

-- result!
declare @h as varchar(1000)
set @h=''
select @h=@h+s from @sql order by id

update #AS set tableScript=@h where tablename=@table
 FETCH NEXT FROM L1 INTO @table

END


 CLOSE L1
 DEALLOCATE L1

 select * from  #AS

Generate Alter Script for Adding Column in Existing table

Some times we are facing issues how to migrate the table(New version) column to old one table (Old version). for that we can  generate the alter script of table.
We have use other option as DB  compare etc.




if exists (

select * from tempdb.dbo.sysobjects o

where o.xtype in ('U')




and o.id = object_id(N'tempdb..#tempTable')

)

DROP TABLE #tempTable;







SELECT

'' + SC.Name + ' ' + ' ' + ST.NAME + ' ' +

CASE

WHEN (ST.Name='bigint') THEN ''

WHEN (ST.Name='binary') THEN ' (' + CONVERT(varchar(10), SC.Length) + ')'

WHEN (ST.Name='bit') THEN ''

WHEN (ST.Name='char') THEN ' (' + CONVERT(varchar(10), SC.Length) + ')'

WHEN (ST.Name='datetime') THEN ''

WHEN (ST.Name='decimal') THEN ' (' + CONVERT(varchar(10), SC.Prec) + ', ' + CONVERT(varchar(10), SC.Scale) + ')'

WHEN (ST.Name='float') THEN ''

WHEN (ST.Name='image') THEN ''

WHEN (ST.Name='int') THEN ''

WHEN (ST.Name='money') THEN ''

WHEN (ST.Name='nchar') THEN ' (' + CONVERT(varchar(10), SC.Length) + ')'

WHEN (ST.Name='ntext') THEN ''

WHEN (ST.Name='numeric') THEN '(' + CONVERT(varchar(10), SC.Prec) + ', ' + CONVERT(varchar(10), SC.Scale) + ')'

WHEN (ST.Name='nvarchar') THEN ''

WHEN (ST.Name='real') THEN ''

WHEN (ST.Name='smalldatetime') THEN ''

WHEN (ST.Name='smallint') THEN ''

WHEN (ST.Name='smallmoney') THEN ''

WHEN (ST.Name='sql_variant') THEN ''

WHEN (ST.Name='sysname') THEN ''

WHEN (ST.Name='text') THEN ''

WHEN (ST.Name='timestamp') THEN ''

WHEN (ST.Name='tinyint') THEN ''

WHEN (ST.Name='uniqueidentifier') THEN ''

WHEN (ST.Name='varbinary') THEN ' (' + CONVERT(varchar(10), SC.Length) + ')'

WHEN (ST.Name='varchar') THEN ' (' + CONVERT(varchar(10), SC.Length) + ')'




ELSE ' ' END + ' ' + CASE WHEN SC.isnullable = 0 THEN ' NOT NULL ' ELSE ' NULL ' END

+ ' ' + CASE WHEN SCmnts.text is not null THEN ' DEFAULT ' + SCmnts.text ELSE '' END AS ColumnScript,

SC.Name into #tempTable

FROM SYSCOLUMNS SC

INNER JOIN SYSTYPES ST ON SC.xusertype = ST.xusertype

LEFT JOIN SYSCOMMENTS SCmnts ON SC.cdefault = SCmnts.ID

WHERE SC.ID IN (SELECT ID FROM SysObjects WHERE [NAME] ='SETUP_USERROLEDETAILS')
select *,

'IF NOT EXISTS(SELECT * FROM sys.columns WHERE name

='''+Name +'''
and object_id=object_id (''dbo.SETUP_USERROLEDETAILS''))

begin

alter table dbo.SETUP_USERROLEDETAILS ADD '+

ColumnScript+'

END' from #tempTable

Friday, January 4, 2013

Formula for Happy Life