Showing posts with label upload. Show all posts
Showing posts with label upload. Show all posts

Friday, March 23, 2012

-R option in BCP

Hi all,
I m trying to use BCP utility to upload a huge text file.
As per microsoft documentation, -R is used to specify the
regional settings. My computer (client) and the sql server
(running in a network machine) has dd/mm/yyyy as the
regional settings. The incomming text file also has date
in dd/mm/yyyy format. But when i execute BCP with -R
option, i still get an invalid date format error message.
I went through a few microsoft support information, that
told me that SP1 should solve this problem. I got SP3a
installed (both in client and in the server).
So what am i missing here? I m sure some of u here
should have also faced the problem. Any type of help is
greatly appreciated.
thanks and regards,
s.ravi sankarAlready answered in several other ng's.
--
Andrew J. Kelly
SQL Server MVP
"Ravi Sankar" <ravi_pv@.lycos.com> wrote in message
news:0aff01c3b026$b426bfb0$a101280a@.phx.gbl...
> Hi all,
> I m trying to use BCP utility to upload a huge text file.
> As per microsoft documentation, -R is used to specify the
> regional settings. My computer (client) and the sql server
> (running in a network machine) has dd/mm/yyyy as the
> regional settings. The incomming text file also has date
> in dd/mm/yyyy format. But when i execute BCP with -R
> option, i still get an invalid date format error message.
> I went through a few microsoft support information, that
> told me that SP1 should solve this problem. I got SP3a
> installed (both in client and in the server).
> So what am i missing here? I m sure some of u here
> should have also faced the problem. Any type of help is
> greatly appreciated.
> thanks and regards,
> s.ravi sankar
>

Tuesday, March 20, 2012

Quick Update/Insert TSQL?

Hi all!

I have a quick question...

'UPLOAD / INSERT EXISTING CLIENT DATA INTO SQL SERVER FROM CLIENT
INSERT INTO ProductLocal
(tblID,SQLkey, CreateDateTime, Alias, ProductNumber, ProductMfgID, ProductDesc, ProductAlt1Number, ProductAlt2Number, ProductCost,
ProductListPrice, ProductVendorID, ProductHier1, ProductHier2, ProductHier3, ProductHier4, ProductHier5, ProductHier6, ProductHier7, ProductHier8,
ProductHier9, ProductCategory, ProductSubCategory, ProductLocalAdd, ProductAddDesc, create_timestamp, update_timestamp, update_originator_id,
create_date)
SELECT tblID, SQLkey, CreateDateTime, Alias, ProductNumber, ProductMfgID, ProductDesc, ProductAlt1Number, ProductAlt2Number, ProductCost,
ProductListPrice, ProductVendorID, ProductHier1, ProductHier2, ProductHier3, ProductHier4, ProductHier5, ProductHier6, ProductHier7, ProductHier8,
ProductHier9, ProductCategory, ProductSubCategory, ProductLocalAdd, ProductAddDesc, create_timestamp, update_timestamp, update_originator_id,
create_date
FROM Product
WHERE (Alias = 'me')

'DOWNLOAD / UPDATE-INSERT EXISTING LOCAL DB (PRODUCT TABLE) FROM SQL SERVER PRODUCTLOCAL TABLE

What would be the best and least expensive way to UPDATE/INSERT the local client db from the SQL Server?

-- LOCAL DB (PRODUCT TABLE) FROM SQL SERVER PRODUCTLOCAL TABLE

Any help would be appreciated.... thanks.

Kind regards,

billb

You can use the following approaches,

1. Linked Server,

Set up Linked Serer on your Local Server,

EXEC master.dbo.sp_addlinkedserver

@.server = N'<LinkedServerName>',

@.srvproduct=N'SQLOLEDB.1',

@.provider=N' SQLOLEDB.1',

@.datasrc=N'<YourServer>',

@.provstr=N'Provider=SQLOLEDB.1;Data Source=<YourServer>;Initial Catalog=<Database name>’,

@.catalog=N'<Database Name>'

GO

Exec sp_addlinkedsrvlogin

@.rmtsrvname = N'<LinkedServerName>',

@.useself = false,

@.locallogin = 'sa',

@.rmtuser = 'sa',

@.rmtpassword = '***************'

Now execute the following query..

INSERT INTO ProductLocal

SELECT *

FROM

<LinkedServerName>.<databasename>.<dbo>.Product

2. Ad-Hoc Distributed Quires

Insert Into ProductLocal

SELECT a.*

FROM OPENROWSET('MSDASQL','DRIVER={SQL Server}; SERVER=<YourServer>; UID=sa; PWD=PASSWORD’, 'Select * from <databasename>.dbo.product') AS a;

3. SQL Server Replication

See, http://msdn2.microsoft.com/en-us/library/ms151198.aspx

|||

Was sort of going for just the TSQL Update/Insert though:

Insert Into ProductLocal

SELECT a.*

FROM OPENROWSET('MSDASQL','DRIVER={SQL Server}; SERVER=<YourServer>; UID=sa; PWD=PASSWORD’, 'Select * from <databasename>.dbo.product') AS a;

Something like:

Update ProductLocal

SELECT a.*

FROM OPENROWSET('MSDASQL','DRIVER={SQL Server}; SERVER=<YourServer>; UID=sa; PWD=PASSWORD’, 'Select * from <databasename>.dbo.product where alias = ' & me & ' & ') AS a;

Not sure how to do the above update tsql...

Thanks,

billb