Today I needed to create a job that moves files on the file system.
despite the recommendetions against xp_cmdshell, I use it because similar jobs do the same, so the SP has to exist on the server anyway. The problem was that running the move command in CMD line worked fine, while running the SQL code returned a "file access denied" exceptions.
Of course, the solution is to give access to the folders to the user that SQL Server runs under. Look at the services in task manager and add the user to the folder.
Thursday, June 2, 2016
xp_cmdshell in SQLServer 2014
Posted by
Radu
at
9:37 AM
0
comments
Wednesday, October 15, 2014
Time Management. By Brian Tracy
Yet another post about a book. But a very good book, in my opinion.
I got "Time Management" as part of O'Reilly blogger program. I have issues with managing my time, I get a lot of things on my dashboard, but they never get done (maybe I want to do too much). So the book is of great interest to me.
The entire thing about time management is based on the principle of the four Ds: desire, decisiveness, determination, and discipline.
The book is divided into 21 chapters and each of them is a few minutes read but can (and should) generate hours of reflection for someone looking to improve the quality of life.
The book starts with Chapter 1: The Psychology of Time Management, a chapter that explains that we are able to control our time budget. Think "as if" you were already the person you want to be.
Chapter 2: Determine Your Values. This chapter speaks about “Why am I doing what I am doing?”. The meaning and purpose of our actions. Of course, is easier to do things that we love and we are more efficient doing those things. Also, defining our goals in life is suppose to help tremendously.
Chapter 3: Think About Your Vision and Mission this chapter refers to Daniel Kahneman’s Thinking, Fast and Slow. The book speaks about the necessity to react fast sometimes and about reflecting to what and why we are doing our actions, thinking more about details. This chapter speaks about not forgetting the goals of our life. Keep the end in mind and examine the methodology. Determine your assumptions and maybe find a better way to accomplish the goal.
Chapter 4: Project Forward, Look Backward
This chapter talks about thinking. And about the importance to take time to think, plan, dream, and create. Think about the longer term future.
Chapter 5: Make Written Plans
Define your goals before you start working. Make a clear plan of what you want to accomplish, break it down in smaller steps. Be prepared to review the plan.
Chapter 6: Chart Your Projects
Talks about a project seen as a collection of smaller tasks. And about the importance of checklists. "A checklist consists of a written series of steps, in chronological order, which you create in advance of beginning work in the first place." The author argues that every minute spent in planning saves you 10 minutes in the execution phase. Also he recommends the use of PERT charts and setting clear goals for everyone.
Chapter 7: Create your daily "TO-DO" list
One can see it as a blueprint for the day. he mentions that "the best time to make a list is the night before, so your subconscious mind can work on your list while you sleep." I would add that while working for a big multinational in Italy I had a colleague who was writing down on paper what he wanted to achieve for the next day. And things were going pretty well for him. The ABCDE Method. The most important word in time management is consequences. A task is important depending on the potential consequences of doing it or not doing it.
The book clearly explains how time wastage (due to bad habits) sabotages careers.
The Not-To-Do List. “No” is the greatest time-saving word in the world of
time management.
Chapter 8: Set Clear Priorities
Ask yourself What is the most valuable use of my time right now?
Is also important to distinguish between important and urgent.
Chapter 9: Stay on Track
Is also important to distinguish between important and urgent.
Chapter 10: Determine Your Key Result Areas
A KRA is:
- something that you absolutely must to
- 100% under your control
- something that you are responsible for
Furthermore, Brian Tracy dedicates special short chapters to the importance of Delegating to the others (chapter 11), concentrating (chapter 12), overcoming procrastination, creating chunks of time and controlling interruptions, batching your tasks and controlling your phone, reading faster and investing in personal development. I'm not going to take you the pleasure of reading the book by describing each of the chapter
All in one, the book is an easy read, easy to understand and the principles are so simple that one has no excuse not putting them in practice and becoming more efficient. So I would highly recommend it to anyone having problems with time management !
Posted by
Radu
at
8:10 AM
0
comments
Monday, October 13, 2014
Operation must use an updateable query
I was getting this error while trying to update an Access database (don't ask me why on Earth I use Access - not my decision). After little (fortunately) struggle I realized the DB was read only. It took some time, because another save operation doesn't work, so I was pointing on the wrong direction.
Posted by
Radu
at
6:03 AM
0
comments
Friday, April 4, 2014
SSIS fails
If you get an error at the running of the Flat File Source SSIS dataflow item
"Task Load {your flat_file} failed" while running a SSIS package (that loads data from a flat file) it might be that you have the flat file opened in Excel. Just for curiosity I tried opening the file in CSVed and it looks like CSVed doesn't keep it locked, the task runs succesfully.
Hope this is saving you some hair pulling.
Posted by
Radu
at
10:40 AM
0
comments
Thursday, March 27, 2014
Maps in SSRS 2008
Yesterday I was getting an error while trying to run a report that contains a map, saying something like this: [...]maps binding or grouping for layer is not valid[...]. I don't remember exactly the entire error message, but I can reproduce it if one is interested.
This was a little tricky because I started to look at the map layer properties, trying to understand what I did wrong in the RDL. Just to find out that the DataSource was returning more than one row per country, so the poor RS didn't know which row to map.
Posted by
Radu
at
3:18 AM
0
comments
Tuesday, February 11, 2014
Think Like a Programmer by V. Anton Spraul, O'Reilly Media
I got this book as part of O'Reilly blogger progam. As a software developer with 14 years of experience myself, I was curious to see what Anton Spraul's book can teach.
You'll not find there the usual pages with code and algorithms that you'll find in many computer programming books. The code you'll find in C++ and is used mostly for exemplification. Is not a book about code, but one about problem solving. Ideas learned can be applied in many other areas of our life.
The book starts with basic logic problems (classic puzzles), the solution to them and the way of thinking that can lead to a solution. Here we learn about being aware of ALL possible actions you could take, creating strategies and simplifying the problem, looking for the most constrained part of the problem, recognizing patterns and analogies. Just as a side note, I'm member of a chess site, where paying members get to try a huge number of tactical problems and this helps a lot in recognizing patterns in the real game. Programming is similar: recognizing patterns and reducing complex problems to known ones.
Then the book goes through specific type of problems in programming, like problems with arrays, pointers and dynamic memory, classes, recursion.
On very interesting chapter is the one about code reusing. It is teaching when is good and when is bad to reuse code, it helps identifying the components and building a "component toolkit" or component knowledge. It makes use of the knowledge acquired in the previous chapters and interestingly teaches which components to use for a specific problem, based on the amount of work, flexibility and maintainability. It not only presents the way to get to a solution, but also comparing two possible solutions to the same problem and choosing the best one.
In all the chapters I didn't type in and compile the code, since I was not interested in coding but in finding patterns of thinking and ways to improve.
The last chapter puts it all together, teaches how to create a development plan by eliminating weaknesses (both coding and design ones) and using the strengths. Also learning a new programming skill is approached systematically and this is approach interesting also for seasoned programmers.
I'll conclude with a quote from the book: "Once you are thinking like a programmer, be proud of your skills. If someone calls you a coder rather than a programmer, say that a well-trained bird could be taught to peck out code—you don’t just write code, you use code to solve problems."
You can find more details about the book and the table of contents on O'Reilly catalog page.
Posted by
Radu
at
6:28 AM
0
comments
Labels: book
Friday, April 19, 2013
Sargable
I didn't know this world. It comes from Search ARGument ABLE (according to wikipedia) and it means (in databases world) a condition that enables the use of indexes
Posted by
Radu
at
1:48 AM
0
comments
Labels: SQL Server
Wednesday, October 31, 2012
null is not nothing
Let's assume we have a table @a Do you think
where a = a
is the same as writing
?
Well, think at it for a second before reading furher. Now run this code
declare @A as table (a varchar(5))
insert into @A values ('a1')
insert into @A values ('a2')
insert into @A values ('a3')
insert into @A values (null)
select * from @a where a = ISNULL(@p, a)
Why ? hmm, there is a nice discussion about DB NULL values here. And in many many other places on the web
Posted by
Radu
at
8:53 AM
0
comments
Labels: SQL Server
Monday, August 13, 2012
Buying the Right Photo Equipment, by Elin Rantakrans, O'Reilly Media
In this 128 pages book, Elin Rantakrans aims to help newbies photographers find the right gadgets to fit their shooting style.
The photo equipment is divided into few major chapters: lenses, filters, tripods, flash, protecting gear, other accessories and computer software.
Browsing through the wide variety of photo equipment, each gear type is presented with the purpose and the photography style that it is better suited for. I like the concise presentation, the pictures to exemplify each usage of the gear and the tips for each photography. However, I'd have definitively preferred to see the settings of each pictures and maybe a short story of why the photographer decided for that lens/gear.
If you are a beginner, the book is a definite must read. Is a very easy lecture that would surely get your photos to a next level. I consider myself an intermediate photographer and I think I had quite a lot to read from. I'm sure the part about flash and the ones about software can give many photographers new ideas.
The book doesn't go into details of specific equipment brands and models, but that would make the book become obsolete very soon after being published. After all, there are plenty of review websites for photography gear, so after one decides what type of equipment he/she needs the search for the right model is a matter of time spent into deciding what's best for your camera + budget + style. Of course, be warned that if you are serious about photography your camera&accessories bag will soon become pretty heavy.
The book is a very useful and very easy reading. I'll definitely recommended it to my friends having photography as their hobby.
Posted by
Radu
at
9:34 AM
0
comments
Thursday, February 2, 2012
Fast Query but Slow Stored Procedure
Few days ago we had a problem that I encountered years ago while working in Italy.
Basically a Stored Procedure is very slow. So slow that we didn't wait for it to finish, it probably more than 30 minutes. Let's not forget to mention that I'm running it on SQLServer 2008.
That query taken outside the stored procedure an run with the same parameters in SQLServer Management Studio runs in only few seconds. Since back in Milan I saw the same behaviour (on SQLServer 2005 that time) I thought I have the answer and can impress the colleagues with a fast solution: using WITH RECOMPILE clause.
However, the result was the same...very slow stored procedure.
After searching the Internet we found the answer here. Parameters sniffing. Explained here as "the process of using the parameter value to estimate selectivity and cardinality".
Indeed, our query is pretty complex and it looks like SQLServer did not know to re-create the execution plan. After changing the parameters' names, everything was OK.
Posted by
Radu
at
2:18 AM
0
comments
Labels: recompile, SQL Server