Friday, March 30, 2012
How to trigger Snapshot and Merge Replication
is PUB)
When insert on server B table1 occur, I need trigger to exec snapshot,
followed by merge replication jobs. The jobs exist on server A.
I know how to create triggers, but not clear on how to trigger a SQL job
from server B to run from server A?
using SQL 2K5
You coyuld set up a linked server and run sp_start_job on server A using a
fully qualified name...
Cheers,
Paul Ibison
sql
Wednesday, March 28, 2012
How to translate into SSIS?
Hi everyone,
My current dutie is translate Vb code into SSIS. The following structure is getting me totally crazy:
sql = "SELECT * FROM TABLE1 WHERE FIELD = XXXX"
rs.execute sql
WHILE NOT RS.EOF
STUFF
ANOTHER SELECT AND ANOTHER LOOP
...
...
INSERT AND DELETE STUFF
END WHILE
Which is the best method in order to reach this goal? I'm trying to by means of OLEDB Source Editor connected to Script Component Task on data flow layer but I'm stuck with this.
I don't want to do cursors or something like that with T-SQL.
Thanks in advance for your inputs/help and regards,
Could you use nested FOREACH containers? Store your initial resultset in a variable, then iterate through that, executing the second SQL statement, storing the results in a variable, and using a second FOREACH to iterate that.|||hi,
using ForEach Loop container on control flow, you mean?
should I use ForEach ADO enumerator, shouldn't?
tia
|||Yes, control flow. Yes, ADO recordset.|||Thank you. I'll test it|||It's easier than I though. I'll use a Script Task on Control Flow task. Just that task,
I don't need nothing else
|||Could you share the script? Stripped of anything specific to your business, of course.
Monday, March 26, 2012
How to tie ? to parameter name?
and dataset. The query is essentially Select * from Table1 where
ClientID = ?
Under Report Parameters I changed the name Parameter1 to CIDParam, so
that it is somewhat meaningful when I call it from code. But when I
try to preview the report, Studio complains that the query can't find
Parameter1. So how do I let Studio know that ? should look at
CIDParam?I go against Sybase and have to do this all the time (unfortunately). Go
back to the dataset tab, click on ..., parameters tab. Remap the query
paramters. Keep in mind that although RS creates the report parameters
automatically for you they are not the same thing. This is where they are
mapped.
Another time you will want to do this is if you want to use the same report
parameter multiple times. For instance you have a from and end date that is
used multiple times in your query.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"dgk" <dgk@.somewhere.com> wrote in message
news:l2jni255jalsgohek00ih5ac2h18vbh33a@.4ax.com...
> In the Visual Studio (2005) designer, I created a report, data source,
> and dataset. The query is essentially Select * from Table1 where
> ClientID = ?
> Under Report Parameters I changed the name Parameter1 to CIDParam, so
> that it is somewhat meaningful when I call it from code. But when I
> try to preview the report, Studio complains that the query can't find
> Parameter1. So how do I let Studio know that ? should look at
> CIDParam?|||On Tue, 10 Oct 2006 12:24:48 -0500, "Bruce L-C [MVP]"
<bruce_lcNOSPAM@.hotmail.com> wrote:
>I go against Sybase and have to do this all the time (unfortunately). Go
>back to the dataset tab, click on ..., parameters tab. Remap the query
>paramters. Keep in mind that although RS creates the report parameters
>automatically for you they are not the same thing. This is where they are
>mapped.
>Another time you will want to do this is if you want to use the same report
>parameter multiple times. For instance you have a from and end date that is
>used multiple times in your query.
Yes, that seems to have done it. Thanks.
Monday, March 12, 2012
How to synchronize 2 tables on different sql servers
How can i synchronize 2 tables on 2 different sql servers 2000
i mean TABLE1(col1, col2, col3, col4) and
TABLE1(col1, col2, col3, col4, col5, col6)
the first 3 colums are the same in rwo tables.
Thanks
--
Message posted via http://www.sqlmonster.comalex via SQLMonster.com (forum@.nospam.SQLMonster.com) writes:
> Hi, anybody can help me.
> How can i synchronize 2 tables on 2 different sql servers 2000
> i mean TABLE1(col1, col2, col3, col4) and
> TABLE1(col1, col2, col3, col4, col5, col6)
>
> the first 3 colums are the same in rwo tables.
Could you be more specific on what you mean. Do you want to synchronize
data or metadata? And what should the synchronization result in?
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks for replay, i want to synchronize
data between two tables? i don't know how to acomplish that.
Maybe u can suggest me some stuff to read about topic?
P.S. i had read your articles about Error Handling very helpful.
thanks
--
Message posted via http://www.sqlmonster.com|||alex via SQLMonster.com (forum@.SQLMonster.com) writes:
> Thanks for replay, i want to synchronize
> data between two tables? i don't know how to acomplish that.
> Maybe u can suggest me some stuff to read about topic?
Well, if you know you are in A and want to go B, I might be able to
help you, if you tell me where A and B are.
But if you don't know where you want to go, then I cannot help you with
that part. "Synchronize the tables" could mean a lot of things, and I'm
not active in this newsgroup to play guessing games.
Please give an example of what you have, and where you want to arrive.
Then we might be able to suggest something.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Ok, sorry about my explanation .
I have two sql servers that runs on different machines
each of sql servers have database (there is not same database) however
there is table (suppose myTable) that is same to two databases and i need
to synchronize between them in this case e.g.
sqlServer1 myTable1
sqlServer2 myTable2
in case some data is changed in [sqlServer1 myTable1] i need that
[sqlServer2 myTable2] will changed too according to [sqlServer1 myTable1]
and not vice versa i.e i need that [sqlServer2 myTable2] will ALLWAYS have
data like [sqlServer1 myTable1]
--
Message posted via http://www.sqlmonster.com|||alex via SQLMonster.com (forum@.SQLMonster.com) writes:
> Ok, sorry about my explanation .
> I have two sql servers that runs on different machines
> each of sql servers have database (there is not same database) however
> there is table (suppose myTable) that is same to two databases and i need
> to synchronize between them in this case e.g.
>
> sqlServer1 myTable1
> sqlServer2 myTable2
> in case some data is changed in [sqlServer1 myTable1] i need that
> [sqlServer2 myTable2] will changed too according to [sqlServer1 myTable1]
> and not vice versa i.e i need that [sqlServer2 myTable2] will ALLWAYS have
> data like [sqlServer1 myTable1]
One method is to set up replication, although a replication topology
for one single table is probably an overkill. Also, that would require
the tables to have the same metadata, and your initial post indicated
that they have different columns.
Another method is to set up SqlServer2 as a linked server on
SqlServer1, and then have a trigger that replicates the data to
the table on SqlServer2. If the network is not always up, or if it is
slow, this can cause updates on Server1 to be slow.
Yet another possibility is to set up Server1 as a linked server on Server2,
and regularly poll, for instance from SQL Server Agent. If the table
is moderate in size, it might be feasible to simply truncate the
table, and then load the data over. Of course, this won't do, if the
table is has many rows.
Yet a possibiliy is a combination of the last two: you have a trigger
which writes to a table local to Server1, and then Server2 pulls the
chagens from this table, and then deletes the rows in the table. Here
some care needs to be taken so that you don't miss any updates, but
also you don't lock the source tables for updates while fetching.
Which of these to choose depends on your exact requirements, which
privileges you can run this under, which possibilities you have to
set up linked servers and create triggers etc.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||thanks, this more that i expect.
--
Message posted via http://www.sqlmonster.com
Friday, February 24, 2012
How to store image datatype value to a variable?
I'm trying to do the following,
DECLARE @.Data varbinary(16)
SET @.Data = (select imageCol from Table1 where id=3)
As image datatype returns varbinary value, so I want to store image col value to a varbinary variable(or any other type variable, eg., varchar). But getting following error,
========================================
Server: Msg 279, Level 16, State 3, Line 2
The text, ntext, and image data types are invalid in this subquery or aggregate expression.
========================================
Is there anyway to store image datatype value to a variable?
Cheers.
Try this:
select @.Data=imageCol from Table1 where id=3
mbanavige wrote:
Try this:
select @.Data=imageCol from Table1 where id=3
Thanks a lot.