Macro VBA with Excel to insert/store image to MSQL Server - sql-server

I have a folder with images (person photo) that need to be used in reporting and I want to save them in a SQL Server table. I am using SQL Server 2012 and I have created a table. I am neither an Admin(sa/dbo) nor I have permissions to use the BULK statement. I searched many sites but found none so far without BULK statement.
I have a userform developed in excel and using VBA to execute the insert query image to connect to sql with SSIS (if I am an admin the insert blob query executed successfully from my workstation) however if I am neither admin(sa/dbo) I tried using other workstation cause I have my sql server set up to allow access remotedly using tcp and open port 443. It fails to insert
Most people suggested using :
INSERT INTO PersonImage
SELECT * FROM
OPENROWSET(BULK "Imagepath", SINGLE_BLOB) AS image
I cannot use this or any statement with BULK in it. Could anyone of you suggest a way arround to load these images into the table with out using BULK INSERT statement?
Your help is appreciated!
Thanks and Regards

Related

Delete Fails using ODBC in SSIS

I changed an Execute SQL Task targeting my default, local SQL Server instance from OLE DB to ODBC. The SQL is
delete from tablename
The ODBC version works fine when the table has records but fails when the table is empty.
I thought about using the result set of another SQL Task to populate a variable but that would not work. Reading this SO article Delete statement fails when called from SSIS identified the source of the problem (ODBC version), but it still didn't provide the answer. Other web articles suggested no workaround.
Are there any other methods or approaches to conditionally call the delete only if the table is not empty?.
It occurred to me to just use T-SQL to solve the problem. I used a T-SQL conditional statement which works fine. The ODBC SQL Task succeeds whether or not the table is empty.
if 0 < (select count(1) from tablename)
delete from tablename

Query from SQL Server tables in Oracle using ODI

I have a database in Oracle and a database in SQL Server.
I want to write a query in Oracle and I need to use one of SQL Serever table in it.
Before I used database link but now I must to do this with ODI (Oracle Data Integrator).
The way I used before:
CREATE PUBLIC DATABASE LINK "DBLINK"
CONNECT TO "MatrisApp" IDENTIFIED BY VALUES ':1'
USING 'dg4msql';
INSERT
INTO everyday_deposit_temp ***/*this is a table in oracle*/***
(
"DEP_ID",
"REF_DEPOSIT_TYPE",
"REF_DEPOSIT_SUB_TYPE",
"LEDGER_CODE_SELF"
)
SELECT "DEP_ID",
"REF_DEPOSIT_TYPE",
"REF_DEPOSIT_SUB_TYPE",
"LEDGER_CODE_SELF"
FROM dbo.vw_deposit_changed#dblink
Please help me with this
The most common way to get data from MS SQL Server to Oracle through ODI is to use LKM MSSQL to ORACLE (BCP SQLLDR).
Now if you really want to use a dblink, I would try this approach:
Duplicate a Oracle IKM you want to use
In the definition tab, check the Multi-Connections checkbox and set Microsoft SQL Server for the Source Technology.
In the Options tab, add a new option DBLINK_NAME with Value type.
In the Tasks tab, find the task responsible of the insert and edit the target command to add this after the table name : #<%=odiRef.getOption("DBLINK_NAME")%>
Create a mapping using the new IKM. In the Physical tab, click on the target table and add the dblink name in the Option.

DB Link from Oracle to MS Server

I am new to this forum and already searched for 45 minutes to find a solution for my problem. I hope you can help me.
A Gateway to a remote Microsoft SQL Database was installed on a Oracle Server (Oracle 12c). The tsnnames.ora file was appropiately set up.
For the connection, I created a database link (In the Oracle DB) as follows:
CREATE DATABASE LINK TEL CONNECT TO "fb_B2C" IDENTIFIED BY "passwort" USING 'dg1msql';
When I now execute the Select statement:
SELECT "name" FROM "sys"."databases"#TEL
it shows me the according databases. Among others, I can see the AB_Colors database.
Now, I want to select a view in the AB_Colors database.
Due to the fact I can connect to this database via Excel, I know that in the database AB_Colors, there are 10 Views(A,B,C,..). I would like to select the View C from the database AB_Colors via the DB LInk.
Owner of the View is b2b.
How do i need to formulate the select statement to do it?
I already tried different writings:
SELECT * FROM b2b.C#TEL;
SELECT * FROM "AB_colors"."b2b"."C"#TEL;
SELECT * FROM [AB_Colors].[b2b].[C]#TEL;
The common error message is: View/Table does not exist
I highly appreciate your help,
Fedja
This is the correct format
SELECT * FROM "b2b"."C"#TEL;
The issue maybe because the database you want to select from is not the one specified in the gateway for dg1msql. You can't add the database name to the query so you must specify it in the gateway connection.
This is defined in
$ORACLE_HOME/dg4msql/admin/initdg4msql.ora
where you should check HS_FDS_CONNECT_INFO

How to copy data from a view of one server into the database table of another server in a SQL server database?

how can i copy data from a view of one server into the database table of another server in a SQL server database without using linked servers method.
I tried using the code:
SELECT [LogEntryID]
,[TimeStamp]
Into [server-2].[database1].[dbo].[table1]
FROM [server-1].[database1].[dbo].[view_1]
I recieve the error " The object name 'server-2.database1.dbo.table1' contains more than the maximum number of prefixes. The maximum is 2.
The copying statement i am using in a groovy code. But for first i am trying it in a query if it works.
You can use opendatasource instead of linked server
insert DestinationTable
select * from opendatasource('SQLOLEDB', 'Server=SourceServer;User Id=Username;Password=Password;').SourceDb.Schema.SourceTable;
OPENDATASOURCE

How to See Actual Data Stored in Table Without Running SQL in SQL Server

I have a database in SQL Server 2012 as:
now can you please let me know how I can I see the actual data stored in the dbo.UserAccount table without running expicitly a SQL command like SELECT * FROM dbo.UserAccount ?
I tried by clicking on the table node but this just expand the collapse columns nodes.
You need to run SELECT ... FROM .... T-SQL is the only API to access SQL Server. You may learn that you can right click a table in SSMS and select 'view top 1000 rows' but that is really just opening a query and running a SELECT.

Resources