Showing posts with label operation. Show all posts
Showing posts with label operation. Show all posts

Wednesday, March 28, 2012

Is it possible to make INSERT/UPDATE operation in SSIS?

Hi!
I use SSIS to insert some data from text sources to SQL server 2005. I use
check constraints option. Is it possible if iserted record has the same
primary key as existing record in table to replace existing record? How to
make it?
Thank you
Igor A. ChechetIgor
BEGIN TRANSACTION
IF EXISTS (SELECT * FROM Table WHERE id=@.id)
BEGIN
UPDATE Table SET col=...,col2...c,ol3=... WHERE id=@.id
END
ELSE
BEGIN
INSERT INTO Table (cols here) VALUES (here)
END
COMMIT TRANSACTION
"Igor A. Chechet" <ichechet@.mail.ru> wrote in message
news:uVHJyuxpGHA.1440@.TK2MSFTNGP03.phx.gbl...
> Hi!
> I use SSIS to insert some data from text sources to SQL server 2005. I use
> check constraints option. Is it possible if iserted record has the same
> primary key as existing record in table to replace existing record? How to
> make it?
> Thank you
> Igor A. Chechet
>|||Igor,
First better to import to a staging table all the records .
You can write a query which checks the existence of a record on Primary
Key
UPDATE TABLE SET COL1= STAGING.A1,
COL2 = STAGING.COL2
...
...
FROM TABLE , STAGING
WHERE TABLE.PK - STAGING.PK
INSERT INTO TABLE
SELECT * FROM STAGING A
WHERE NOT EXISTS ( SELECT 1 FROM TABLE B WHERE B.PK =A.PK)
Note: PK is PRIMARY KEY
M A Srinivas
Igor A. Chechet wrote:
> Hi!
> I use SSIS to insert some data from text sources to SQL server 2005. I use
> check constraints option. Is it possible if iserted record has the same
> primary key as existing record in table to replace existing record? How to
> make it?
> Thank you
> Igor A. Chechet|||There's no need to drop to an intermediary table. You can do this in the
pipeline.
Here's how: http://www.sqlis.com/default.aspx?311
Regards
Jamie Thomson
An SSIS blog - http://blogs.conchango.com/jamiethomson/
<masri999@.gmail.com> wrote in message
news:1152880213.339951.42940@.i42g2000cwa.googlegroups.com...
> Igor,
> First better to import to a staging table all the records .
> You can write a query which checks the existence of a record on Primary
> Key
> UPDATE TABLE SET COL1= STAGING.A1,
> COL2 = STAGING.COL2
> ...
> ...
> FROM TABLE , STAGING
> WHERE TABLE.PK - STAGING.PK
> INSERT INTO TABLE
> SELECT * FROM STAGING A
> WHERE NOT EXISTS ( SELECT 1 FROM TABLE B WHERE B.PK =A.PK)
> Note: PK is PRIMARY KEY
> M A Srinivas
>
>
> Igor A. Chechet wrote:
>

Is it possible to make INSERT/UPDATE operation in SSIS?

Hi!
I use SSIS to insert some data from text sources to SQL server 2005. I use
check constraints option. Is it possible if iserted record has the same
primary key as existing record in table to replace existing record? How to
make it?
Thank you
Igor A. ChechetIgor
BEGIN TRANSACTION
IF EXISTS (SELECT * FROM Table WHERE id=@.id)
BEGIN
UPDATE Table SET col=...,col2...c,ol3=... WHERE id=@.id
END
ELSE
BEGIN
INSERT INTO Table (cols here) VALUES (here)
END
COMMIT TRANSACTION
"Igor A. Chechet" <ichechet@.mail.ru> wrote in message
news:uVHJyuxpGHA.1440@.TK2MSFTNGP03.phx.gbl...
> Hi!
> I use SSIS to insert some data from text sources to SQL server 2005. I use
> check constraints option. Is it possible if iserted record has the same
> primary key as existing record in table to replace existing record? How to
> make it?
> Thank you
> Igor A. Chechet
>|||Igor,
First better to import to a staging table all the records .
You can write a query which checks the existence of a record on Primary
Key
UPDATE TABLE SET COL1= STAGING.A1,
COL2 = STAGING.COL2
...
...
FROM TABLE , STAGING
WHERE TABLE.PK - STAGING.PK
INSERT INTO TABLE
SELECT * FROM STAGING A
WHERE NOT EXISTS ( SELECT 1 FROM TABLE B WHERE B.PK =A.PK)
Note: PK is PRIMARY KEY
M A Srinivas
Igor A. Chechet wrote:
> Hi!
> I use SSIS to insert some data from text sources to SQL server 2005. I use
> check constraints option. Is it possible if iserted record has the same
> primary key as existing record in table to replace existing record? How to
> make it?
> Thank you
> Igor A. Chechet|||There's no need to drop to an intermediary table. You can do this in the
pipeline.
Here's how: http://www.sqlis.com/default.aspx?311
Regards
Jamie Thomson
An SSIS blog - http://blogs.conchango.com/jamiethomson/
<masri999@.gmail.com> wrote in message
news:1152880213.339951.42940@.i42g2000cwa.googlegroups.com...
> Igor,
> First better to import to a staging table all the records .
> You can write a query which checks the existence of a record on Primary
> Key
> UPDATE TABLE SET COL1= STAGING.A1,
> COL2 = STAGING.COL2
> ...
> ...
> FROM TABLE , STAGING
> WHERE TABLE.PK - STAGING.PK
> INSERT INTO TABLE
> SELECT * FROM STAGING A
> WHERE NOT EXISTS ( SELECT 1 FROM TABLE B WHERE B.PK =A.PK)
> Note: PK is PRIMARY KEY
> M A Srinivas
>
>
> Igor A. Chechet wrote:
>> Hi!
>> I use SSIS to insert some data from text sources to SQL server 2005. I
>> use
>> check constraints option. Is it possible if iserted record has the same
>> primary key as existing record in table to replace existing record? How
>> to
>> make it?
>> Thank you
>> Igor A. Chechet
>

Friday, February 24, 2012

Is DBCC DBReindex minimally logged operation?

Hi gurus,
Does anyone know whether DBCC DBReindex is a minimally logged operation or
fully logged operation?
Thanks,
Jeff" fully logged "
--
"Jeffrey Yao" wrote:

> Hi gurus,
> Does anyone know whether DBCC DBReindex is a minimally logged operation or
> fully logged operation?
> Thanks,
> Jeff
>
>|||It is minimally logged when the database is in simple or bulk logged recover
y mode.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jeffrey Yao" <jxhyao1@.shaw.ca> wrote in message news:%235UKdhHqFHA.1556@.TK2MSFTNGP12.phx.g
bl...
> Hi gurus,
> Does anyone know whether DBCC DBReindex is a minimally logged operation or
> fully logged operation?
> Thanks,
> Jeff
>

Monday, February 20, 2012

Is Busy: ...waiting to complete an internal operation

Frequently, when I'm connecting to my server through SSMS i get "Is Busy: Microsoft SQL Server is waiting to complete an internal operation...."

And it tells me that if I get that message a lot, I should let Microsoft know.

So -- Microsoft, I'm letting you know.

Can anyone tell me why this is happening? I've searched MSDN and the knowledge base...I can only find one reference, and that is to a database diagram issue.

It takes a while to connect when this happens. So far, I haven't found a common denominator. It happens if I'm logged into my server and I try to connect to another instance, and it happens when I'm using my desktop...

As phrased above, the message does not appear to match any database engine error message, so it is probably from SSMS itself so you might want to post to the tools forum instead of the engine forum.

|||

How would I do that without double-posting?

Can the moderator move this for me?