Monday, April 27, 2020

python -m pip install Scrapy - error: command 'cl.exe' failed: No such file or directory

While Installing Scrapy library in windows in case if you receive "Command 'cl.exe' failed" error means the system doesn't have Microsoft C Compiler or Environment path not set properly.

To Fix this error try installing Desktop Development with C++ from Visual Studio Installer.  After installing it try running this command in windows Command prompt python -m pip install Scrapy



Sunday, April 26, 2020

HowTo update PIP

Sometime we need to upgrade PIP in our machine. to upgrade use this command python -m pip install --upgrade pip in the windows command prompt.


pip install matplotlib - SyntaxError: invalid syntax


When we are trying to install mapplotlib using PiP command into the python interactive prompt then it will throw invalid syntax error. To Over come this issue try running this command windows command prompt "python -m pip install matplotlib" Note: before running this command install python in the machine.


Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> pip install matplotlib
  File "", line 1
    pip install matplotlib
        ^
SyntaxError: invalid syntax

Friday, May 13, 2016

SSRS 2005 - How To Format Globals!ExecutionTime To "MM/dd/yyyy"


To format the build-in global in SSRS 2005 you have to you  FORMAT functions which will take two parameters (Expression & Style)


Example

         = FORMAT(Globals!ExecutionTime, "MM/dd/yyyy") 

Friday, August 14, 2015

Select Query - Case Statement In Order by - Msg 241 - Conversion failed when converting datetime from character string Error

        Today when i was working on store procedure which i need to use case statement in Order by in the select clause i have came across the following issue,

Msg 241, Level 16, State 1, Line 16
Conversion failed when converting datetime from character string.


        After a spending some time I found the root cause of this issue, the golden rule we have to use the same type in all the branches of case/when.

Sample Code

Execute the below sample script to recreate that issue,

DECLARE @tmpTBL table
(
    ID INT IDENTITY(1,1),
    SampleDT datetime
)

INSERT INTO @tmpTBL VALUES('2015-08-01');
INSERT INTO @tmpTBL VALUES('2015-08-02');
INSERT INTO @tmpTBL VALUES('2015-08-03');
INSERT INTO @tmpTBL VALUES('2015-08-04');

Declare @SordDirection CHAR(1); SET @SordDirection = 'D';
Declare @OrderBy VARCHAR(10);SET @OrderBy = 'SampleDT';

SELECT * FROM @tmpTBL
ORDER BY
        CASE WHEN @SordDirection ='D' THEN 'A'
        ELSE
        CASE WHEN @OrderBy = 'SampleDT' THEN SampleDT
        END
        END ASC,
        CASE WHEN @SordDirection='A' THEN 'D'
        ELSE
        CASE WHEN @OrderBy = 'SampleDT' THEN SampleDT
        END
        END DESC












 

Replace the  CASE WHEN @OrderBy = 'SampleDT' THEN SampleDT with the following line 
CASE WHEN @OrderBy = 'SampleDT' THEN CAST(SampleDT as VARCHAR(12))

After replacing if you execute the script, you can see the results without any issues,





 







 
Complete Script

DECLARE @tmpTBL table
(
    ID INT IDENTITY(1,1),
    SampleDT datetime
)
INSERT INTO @tmpTBL VALUES('2015-08-01');
INSERT INTO @tmpTBL VALUES('2015-08-02');
INSERT INTO @tmpTBL VALUES('2015-08-03');
INSERT INTO @tmpTBL VALUES('2015-08-04');

Declare @SordDirection CHAR(1); SET @SordDirection = 'D';
Declare @OrderBy VARCHAR(10);SET @OrderBy = 'SampleDT';

        SELECT * FROM @tmpTBL
ORDER BY
        CASE WHEN @SordDirection ='D' THEN 'A'
        ELSE
        CASE WHEN @OrderBy = 'SampleDT' THEN CAST(SampleDT as VARCHAR(12))
        END
        END ASC,
        CASE WHEN @SordDirection='A' THEN 'D'
        ELSE
        CASE WHEN @OrderBy = 'SampleDT' THEN CAST(SampleDT as VARCHAR(12))
        END
        END DESC