Wednesday, September 18, 2013

Enable SQL-Server Agent for non-admin User

Non-admin users will have public access to their databases, and usually SQL Server agent won't show in their Management studio. If you want the public user to create or manage or execute the Jobs in the SQL SERVER, you have to add 3 important SQL Agent fixed database roles to the msdb database.

 SQLAgentUserRole
-  SQLAgentReaderRole
-  SQLAgentOperatorRole


How to add those roles


1. Navigate through Object Explorer -> Security -> Logins(select the user, then right click) -> Properties -> User Mapping -> Login Properties.

2. Select msdb database.

3. Select SQLAgentUserRole, SQLAgentReaderRole and  SQLAgentOperatorRole under Database role membership for : msdb.

That's it. You are good to go....


Monday, September 16, 2013

Wrap up the content in Div and adjust the height and width dynamically

One line CSS3 Property

word-break:break-all;
(or)
word-wrap:break-word;
Works in all browser

.append_data{
   white-space: pre-wrap;      /* CSS3 */   
   white-space: -moz-pre-wrap; /* Firefox */    
   white-space: -pre-wrap;     /* Opera <7 */   
   white-space: -o-pre-wrap;   /* Opera 7 */    
   word-wrap: break-word;      /* IE */
}

Sunday, September 15, 2013

Compare the string, int and nText with a string in TSQL

Compare the string, int and nText data type with a string data type in  CASE WHEN TSQL

In this case, Column1 is a string, 
    
    select case when column1 = 'sometext' then 1 else 0 end
    from table1

In this case, Column1 is an integer, 

    select case when cast(column1 as varchar(max)) = 'sometext' then 1 else 0 end
    from table1

In this case, Column1 is a nText, 

    select case when cast(column1 as nvarchar(max)) = N'sometext' then 1 else 0 end
    from table1


Friday, September 13, 2013

Install PostgreSQL in Mac OX

You can install the PostgreSQL in MacOX in either way using Graphical Interface or through HomeBrew.

Click Here to choose the options : http://www.postgresql.org/download/macosx/

Here, I have used  Graphical installer

Before installing always make sure you are having the maximum shared memory. It is safe to begin the installation, it wont reserve any memory, so there in no harm...

To check the Shared memory : $ sysctl -a

kern.sysv.shmmax=1610612736
kern.sysv.shmall=393216
kern.sysv.shmmin=1
kern.sysv.shmmni=32
kern.sysv.shmseg=8
kern.maxprocperuid=512
kern.maxproc=2048

If you don't have this config, please update your file $sudo vi /etc/sysctl.conf
[You can also get this info in Readme file.]

After editing, restart the machine, to install Postgres.

Double click the "postgresql-9.3.0-1-osx" and just follow the instruction.

To check whether Postgres is installed or not,

Run this cmd on the terminal :
psql -p 5432 -h localhost -U postgres --password

If it comes to the promt "postgres=#", then you are all set... Quit from the postgres console "\q"



Thursday, September 12, 2013

Tuesday, September 10, 2013

Ruby Predefined Variables

This is a list of the frequently used predefined variables in ruby:

Exceptions
$! message of the last exception
$@ backtrace of the last exception

Regexp
$& the string that matched the last last regexp match
$` string preceding $&
$’ string following $&
$+ last parentheses match
$1, $2, $3… parentheses matches
$~ MatchData object containing information about the last match
$= case insensitive flag

Separators
$/ used by gets, readline etc. as a separator (defaults to “\n”)
$\ used by print, write etc. as a separator (defaults to nil)
$, used by Array#join
$; used by String#split

IO
$< program input
$> program output
$stdin standard input
$stdout standard output
$stderr standard error output
$. line number of the last read file
$_ last input line - used by gets, readline

Process
$0 program name
$* command line arguments
$$ PID of the program
$? exit status of the last process
$: $LOAD_PATH
$” all filenames required by the script
$SAFE security level 0-4, 0 having no restrictions and being the default
$DEBUG debugger enabled?

Friday, September 6, 2013

TryRuby

Learn ruby basic commands in 15 minutes using the link http://tryruby.org, Which has command line interpreter, and you can have short desc for each command. You can go back and forth to check.