2014-12-29

VBA - Excel web service call through XMLHttp

You will need a reference to the library "Microsoft XML, v6.0".


Sub getWebServiceX()

    Dim req As New MSXML2.XMLHttp

    req.Open _
        "GET" _
        , "http://www.webservicex.com/stockquote.asmx/GetQuote?symbol=GOOG" _
        , False
        
    req.send
    MsgBox req.responseText

End Sub

VBA - XMLHttp.open access is denied

If you get an access denied error, then your windows/internet explorer security settings might not be letting you access the URL being requested pro grammatically.


  • Use the URL over HTTPS if available (change the URL from http:// to https://).
  • Relax your security settings.


2014-11-08

TSQL - Integer Percentiles

select
       T1.Field1

       , PERCENT_RANK()
              over( order by Field1 asc ) as PercentRank

       , cast(
              round(
                     PERCENT_RANK()
                           over( order by Field1 asc )
                     * 100
                     , 0
              )
              as int
       ) as PercentRankInt
from
       (
                             select 1 as Field1
              union all select 1
              union all select 1
              union all select 2
              union all select 2
              union all select 3
              union all select 4
              --union all select 8
       ) as T1
order by
       Field1
; 



PercentRankInt calculates the percentile each value occupies in relation to all other values in the column, as an integer number, ready to be used for quick filters, thus enabling the exclusion of, for example, top and bottom deciles, quintiles, etc.

2014-09-18

TSQL - MSDTC on server is unavailable.

Go to "Services", and start the "Distributed Transaction Coordinator" service.

TSQL - Stored procedure results insertion into table at linked server - No columns or permissions

ISSUE:

The OLE DB provider "SQLNCLI11" for linked server "LINKED_SERVER_NAME_HERE" indicates that either the object has no columns or the current user does not have permissions on that object.



USE THIS METHOD:


insert THESIS.dbo.ExposureCFLM
(
       Field1
       , Field2
       , Field3
)
execute(
 '
       set fmtonly off
       exec DATABASE_NAME_HERE.dbo.STORED_PROCEDURE_NAME_HERE
              @prm1=222
                     , @prm2 = ''aBC''
       ;
') at LINKED_SERVER_NAME_HERE;


 00

TSQL - Server is not configured for RPC

exec sp_serveroption
       @server='me'
       , @optname='rpc'
       , @optvalue='TRUE'
;

exec sp_serveroption
       @server='me'
       , @optname='rpc out'
       , @optvalue='TRUE'
;



TSQL - Restore database from .mdf, recreating the log

CREATE DATABASE THESIS ON
    (FILENAME = N'C:\MSSQL\PATH...\DATABASE_FILE.mdf')
    FOR ATTACH_REBUILD_LOG
;