Experience Sharing, SQL Databases

[SQL] Grant User Permissions

The task which I was doing today required me to prepare a SQL script which grants the user to execute the user defined functions and stored procedures. While SQL Server Management Studio allows us to set the permission by a few clicks, it is good to prepare them using the script so we can re-use them in case we have run them in the development and production databases.

A simple script to grant user with execute permission for stored procedures. It applies to all stored procedures in the selected database.

/* GRANT EXECUTE TO THE ROLE */
GRANT EXECUTE TO <user>

Next, I found out that my application needs to set permission for the user defined functions. I felt I could have spent the same amount of time to search the script to automate the process and manually wrote the script one by one. The script below can help,

/* GRANT EXECUTE TO THE USER DEFINED FUNCTIONS */
SELECT 'GRANT EXECUTE ON [' + SCHEMA_NAME(schema_id) + '].[' + [name] + '] TO MyRole;'
FROM sys.objects
WHERE type IN ('TF','FN');

There is another script which could help,

declare @name varchar(100), @qry varchar(2000)
declare cursor cursor_temp
for select name from dbo.sysobjects where OBJECTPROPERTY (id, IsProcedure) = 1
open cursor_temp
fetch next from cursor_temp into @name
while @@fetch_status = 0
begin
set @qry = ' grant execute on [dbo].[' + @name + ' ] to [ <user_name> ]'
exec (@qry)
fetch next from cursor_temp into @name
end
close cursor_temp
deallocate cursor_temp

I hope this could help.

Advertisements
Experience Sharing

Day 179

Yesterday’s night, I spent my evening with my friend walking from Kallang to Geylang for hearty dessert before we continued our walk all the way to Kembangan MRT before going home. Throughout the whole journey, we talked a lot of things, from work to life and relationship. She shared her stories, her sisters’ stories and her friends’ stories to convinced me, sometimes I should just create my own opportunity instead of waiting it to happen one day or just pray hard to the God everyday, hope things will just turn up in front of us.

Today’s little baby step surprised me with an immediate reply which seemed to reading my mind. I shared the conversation with my friend. My friend did not come surprised by the answer. Now, I have to spend a bit time to search where the venue to be. I shall praise the Lord for His blessing. I believed the prayer I made this morning was listened by Him and He provided what I wanted when, I was wondering how I could do it when it seemed not a right time.

Data Science & Analytics, Experience Sharing, Web Development

Don’t be afraid to ask for what you want

After the first time meet up with the mentor, I wrote an email to my CTO to seek his advice. He replied saying that email was not an email, it was a conversation. He spent some time to reply me with 3 emails and I summarized them with two things he wanted me to think about.

How long would I want to be a software developer?
After I switched my career into BI development, I involved in some coding works. I did some few years back as a .net software engineer. I would not want to do coding forever, I can code once a while, but I wanted to keep moving, learn new things, gain knowledge in those areas that interest me.

What I want to do?
When I told him what I wanted to do, I gave him a vast area of interests. He tried to explain each of them except things related to data science and data analytics. So, when I replied him, I made a clearer statement, I loved to work with data and slightly narrowed down my scope by telling him what I expected to achieve in near future.

Up to this point, I am glad that he listened and supported me. Making sure I articulate my interest and have my voice and presence is important for other to have a good understanding of who you are. Direct and open is essential for success.

Getting a mentor.
Find someone who appreciates you and your skill and that is in a position to support you. That person has to be well respected, senior and their opinions need to carry a lot of weight.

Be yourself.
Lastly, do not be afraid to ask question when you do not know something. When I first started the data science course in Coursera, I remembered the first words I learned is curiosity.

“There are going to be people who don’t like the way you do something or don’t like you for any particular reason. Don’t let the fear of that hold you back—there’s so much potential out there.” – https://techbeacon.com/women-software-development-8-success-stories-5-tips-advancement.

Data Science & Analytics, Experience Sharing

Mentorship Program

It was back in February 2018 when I saw the mentorship program under the Data Science user group. Like everyone else who wanted to be mentored, it was a golden opportunity to get advice and guidance from the experienced people and move into this field. Two months later, I received an email notification from the user group and informed me I was chosen to be part of the program.

Know your mentor before meet up.

Alright, I should admit, I did not know anyone from the list of the mentors and I did not do any further checks on their profiles to find who is the most suitable person to be my mentor before submitting the application. I did not do an extensive search on my mentor’s profile, I just did not want to appear to be a stalker.

Know what you want.

Our first meet up was a bit awkward as I appeared to be unprepared and I was confused what should a mentor do and what should a mentee do. I wanted to understand what mentor has had to do so I can figure out what path I should take. However, the mentor asked me what I want to do. At that moment, I was not clear.

Mutual mentorship.

Do not underestimate the mutual benefits of the constructive mentor-mentee relationship for both parties. For the mentors, the satisfaction of helping someone else achieve his or her goals is undeniable. My mentor has asked me to read up more articles and blogs to get more sense of the information and resources and attend the regular user group meet up.

Experience Sharing

You Alone Are Irreplaceable

You Alone Are Irreplaceable (唯獨你是不可取替)

It is a Cantonese song, originated from two Japanese singers, Miho Nakayama and Uesugi Shou. The Cantonese version has the male and female versions, sang by Andy Hui and Sammi Cheng. Recently, this song has been added into my song playlist. There is a couple of meaningful words from the lyrics and of course, the title itself is meaningful too.

I cannot read Chinese by myself, however, I managed to get some of the lyric translated into English. The whole song is about an irreplaceable love of a person.

All love stories left people lamented with sad feeling. Do not dare to believe true love.  But, your unconditionally love toward me, surprised me. I am willingly and passionately love you. If today, I am going to lose everything in front of my eyes, leaving with nothing, you are the only one (person) that cannot be replaced. You are my everything in my life.

If I had known we are destined to fall in love with each other, I would have worked hard for our future. For my next life, allows me to stay with you and continue to love you.

Asking what I want the most, I am asking you to entrust your life to me. I will take good care of you and emphasize with your needs. Unconditionally, give all the love to you.

–End.

Experience Sharing

Scala Programming – Window Setup

It has been a year since after I left the Coursera – Functional Programming Principles in Scala course unattended. I joined the free course when I was told that my next projects would be all in Scala and Coursera offered the introduction course. I followed the first few tracks and stopped after I setup and wrote my first Scala code in Linux environment. From a Window based user to Linux, I admitted I struggled along the way until one day, I realized I did not really use my Window’s laptop as often as I used to.

Recently, I went through the same course again and this time, I would like to share the experience of setting up the Window machine. It is quite straight forward for Window’s users and it is easy.

Download the msi installer from the scala-sbt.org website and install it accordingly. After it completes, open the command prompt from Window machine and type,

sbt about

It ran through plenty of new directories and new files and then I received a problems summary, unresolved dependencies org.fusesource.jansi#jansi;1.11: not found and the last message received before the process ended was,

:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.fusesource.jansi#jansi;1.11: not found
Error during sbt execution: Error retrieving required libraries
(see C:\Users\Li Yen\.sbt\boot\update.log for complete log)
Error: Could not retrieve jansi 1.11

I tried to re-run the sbt about from the command prompt again. This time, it was downloading files and updates. The process ended with the following information,

[info] Updated file C:\Users\Li Yen\project\build.properties: set sbt.version to 1.1.4
[info] Loading project definition from C:\Users\Li Yen\project
[info] Updating ProjectRef(uri("file:/C:/Users/Li%20Yen/project/"), "li-yen-build")...
[info] Done updating.
[info] Set current project to li-yen (in build file:/C:/Users/Li%20Yen/)
[info] This is sbt 1.1.4
[info] The current project is ProjectRef(uri("file:/C:/Users/Li%20Yen/"), "li-yen") 0.1.0-SNAPSHOT
[info] The current project is built against Scala 2.12.4
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, sbt.plugins.Giter8TemplatePlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.12.4

Does anyone encounter the same unresolved dependencies message and unable to retrieve jansi? Does it have any relations to Internet connection? I wish to know whether it will affect anything in the future.

Breakfast & Brunch, Experience Sharing, Malaysia - Kuala Lumpur, Malaysian Food

McDonald’s Mix and Match

McDonald’s in Malaysia is having the mix and match for McBreakfast selection. I went to the McDonald’s located at Desa Pandan, Kuala Lumpur, Malaysia with my aunt last week, when I went back to KL for a short break.

The mix and match selection allows us to buy two items with a fixed price which I think it is quite worth especially we do not want to eat the hash-browns. We ordered the two sets of the Sausage McMuffin with Egg with coffee. Instead of the usual McDonald’s paper cup, this visit they used the McCafe’s paper cup.

Although there is some changes, the food quality remains the same and I love the coffee’s smell. I love spending the quality time together with my aunt especially I shared with her my work and my daily life in Singapore. She loves to hear all this stories from me.