Thursday, June 24, 2010

query to find keyword in a column for a table


declare @TableName nvarchar(max)
declare @ColumnName nvarchar(max)
declare @SearchStr2 nvarchar(max)
declare @SearchStr nvarchar(max)
set @TableName='alphaitems_new'
set @ColumnName='iteminfo'
set @SearchStr='FCF Yld'
SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')
EXEC
(
'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
FROM ' + @TableName + ' (NOLOCK) ' +
' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
)

Monday, June 21, 2010

Indian rupee format in crystal reports

numbervar RmVal:=0;
numbervar Amt:=0;
numbervar pAmt:=0;
stringvar InWords :="Rupees ";

Amt := 2512000 ;


if Amt > 10000000 then RmVal := truncate(Amt/10000000);
if Amt = 10000000 then RmVal := 1;

if RmVal = 1 then
InWords := InWords + " " + towords(RmVal,0) + " crore"
else
if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " crores";


Amt := Amt - Rmval * 10000000;

if Amt > 100000 then RmVal := truncate(Amt/100000);
if Amt = 100000 then RmVal := 1;

if RmVal = 1 then
InWords := InWords + " " + towords(RmVal,0) + " lakhs"
Else
If RmVal > 1 then InWords := InWords + " " + ToWords(RmVal,0) + "Lakhs";

Amt := Amt - Rmval * 100000;

if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0);

pAmt := (Amt - truncate(Amt)) * 100;

if pAmt > 0 then
InWords := InWords + " and " + towords(pAmt,0) + " paisa only"
else
InWords := InWords + " only";

UPPERCASE(InWords)