Dependencies Not Correct With Temporary Tables --&&> Replication Is Failing
Jul 13, 2006
Hello all,
here is a stored procedure I have:
CREATE PROCEDURE spU_GUI_AppliqueConditionFinancementPourGuichet
(
@GuichetId int,
@Validateur nvarchar(40)
)
AS
CREATE TABLE #tReservations (ReservationId int)
IF (dbo.GetSiGuichetEnRegle(@GuichetId) = 0)
INSERT #tReservations
EXECUTE spU_GUI_AppliquePerteFinancement @GuichetID, @Validateur
ELSE
INSERT #tReservations
EXECUTE spU_GUI_AppliquePerteAgrement @GuichetID, @Validateur
SELECT GR.Id,
dbo.FormateNoms(GR.Name) AS Names
FROM #tReservations
LEFT JOIN AnotherTable GR ON GR.Id = AnotherTable.id
DROP TABLE #tReservations
GO
The creation is ok but when I look to the dependencies, I see that it depends on GetSiGuichetEnRegle only.
For me, it shall also depend on
AnotherTable
spU_GUI_AppliquePerteFinancement
spU_GUI_AppliquePerteAgrement
FormateNoms
Apparently the dependencies are not calculated correctly because I'm using a temporary table.
My problem is that I have updated this stored procedures (and the two other that I call) to add a new parameter. As a consequence, when I do a replication, this is failing saying that I have an extra parameter. I imagine that because my dependencies are not correct, the replication is not occuring in the correct order and so it's still using the old definition of the stored procedure.
Do you have any idea on how I can force the dependencies to be calculated correctly ?
Thanks
View 3 Replies
ADVERTISEMENT
May 3, 2004
Machine is Windows XP, Client is SQL2K . I tried rebooting without any luck. Uninstalled , reinstalled. After reboot when I try using SQL Clients (EM or QM) it returns the same errors regarding some Ordinal 29 and a big key from registry.. Please help
View 1 Replies
View Related
Mar 1, 2006
I'm converting an existing production replication process to SQL 2005 for testing. My snapshot for a merge replication is failing.
Environment: Single XP server, no filters, @schema_option = 0x000000000C034DD1
I have several snapshot jobs in my process, 2 for transactional replication and 2 for merge replications. In both types, I'm replicating from A to B and then from B to C. In the failing job, I'm merge replicating from B to C. In this failing snapshot job, the error messages are:
2006-03-01 18:42:17.22 [58%] Bulk copying snapshot data for article 'MyName1'
2006-03-01 18:42:17.34 [58%] Bulk copied snapshot data for article 'MyName2' (0 rows).
2006-03-01 18:42:17.41 [58%] Bulk copied snapshot data for article 'MyName1'(195 rows).
2006-03-01 18:42:29.84 [61%] Discovering dependencies among article objects in the specified publication
2006-03-01 18:42:33.66 [61%] The replication agent had encountered an exception.
2006-03-01 18:42:33.66 Source: Unknown
2006-03-01 18:42:33.66 Exception Type: Microsoft.SqlServer.Management.Smo.FailedOperationException
2006-03-01 18:42:33.66 Exception Message: Discover dependencies failed.
2006-03-01 18:42:33.66 Message Code: Not Applicable
2006-03-01 18:42:33.66
Does anyone have an idea what I could look for to try and fix this?
The A to B snapshot obviously uses the same tables. My snapshot for merge job (which worked) messages for the A to B snapshot are:
Message
2006-03-01 18:40:24.98 Time spent analyzing foreign key references (seconds): 0.00
2006-03-01 18:40:24.98 Time spent analyzing check and default constraint references (seconds): 0.19
2006-03-01 18:40:24.98 Time spent analyzing non-article object dependencies (seconds): 0.42
2006-03-01 18:40:24.98 Time spent preparing snapshot generation (seconds): 35.49
2006-03-01 18:40:24.98 Time spent generating merge replication procedures (seconds): 41.39
2006-03-01 18:40:24.98 Time spent generating merge replication stored procedure scripts for subscribers (seconds): 20.66
2006-03-01 18:40:24.98 Time spent bulk copying data (seconds): 1.25
2006-03-01 18:40:24.98 Time spent copying/compressing generated file (seconds): 0.00
2006-03-01 18:40:25.00 Time spent adding rowguid columns/creating merge triggers (seconds): 1.38
2006-03-01 18:40:25.00 Time spent posting snapshot commands (seconds): 25.97
2006-03-01 18:40:25.00 *******************************************************************************
I kicked off the job again and got a different error message:
Message
2006-03-01 19:17:30.32 ---------------------------------------------
2006-03-01 19:17:30.32 -BcpBatchSize 100000
2006-03-01 19:17:30.32 -HistoryVerboseLevel 2
2006-03-01 19:17:30.32 -LoginTimeout 15
2006-03-01 19:17:30.32 -QueryTimeout 1800
2006-03-01 19:17:30.32 ---------------------------------------------
2006-03-01 19:17:30.32 Connecting to Publisher 'xxx-xxxxxxxx'
2006-03-01 19:17:30.34 Publisher database compatibility level is set to 90.
2006-03-01 19:17:30.36 Retrieving publication and article information from the publisher database 'xxx-xxxxxxxx.xxxxxxxxx'
2006-03-01 19:17:30.54 [0%] The replication agent had encountered an exception.
2006-03-01 19:17:30.54 Source: Replication
2006-03-01 19:17:30.54 Exception Type: Microsoft.SqlServer.Replication.ReplicationAgentSqlException
2006-03-01 19:17:30.54 Exception Message: Data is Null. This method or property cannot be called on Null values.
2006-03-01 19:17:30.54 Message Code: 52006
2006-03-01 19:17:30.54
Does that help provide a clue?
View 7 Replies
View Related
May 11, 2015
I got a request to truncate some tables on our testing servers.There are only 11 tables and i could go in and truncate them one after the other, but i need a script that i can use to truncate all the tables at a go. The tables also have no dependencies between them. A script to accomplish the same task if the tables had dependencies ...
View 4 Replies
View Related
Dec 1, 2007
I need to write a code for remove dependencies between Table1.Prikey and Table2.Idand add dependencies between Table1.Prikey and Table3.Id how to write the code? please help .. thank you very much
View 2 Replies
View Related
Oct 5, 2007
Firstly I consider myself quite an experienced SQL Server user, andamnow using SQL Server 2005 Express for the main backend of mysoftware.My problem is thus: The boss needs to run reports; I have designedthese reports as SQL procedures, to be executed through an ASPapplication. Basic, and even medium sized (10,000+ records) reportingrun at an acceptable speed, but for anything larger, IIS timeouts andquery timeouts often cause problems.I subsequently came up with the idea that I could reduce processingtimes by up to two-thirds by writing information from eachcalculationstage to a number of tables as the reporting procedure runs..ie. stage 1, write to table xxx1,stage 2 reads table xxx1 and writes to table xxx2,stage 3 reads table xxx2 and writes to table xxx3,etc, etc, etcprocedure read final table, and outputs information.This works wonderfully, EXCEPT that two people can't run the samereport at the same time, because as one procedure creates and writesto table xxx2, the other procedure tries to drop the table, or read atable that has already been dropped....Does anyone have any suggestions about how to get around thisproblem?I have thought about generating the table names dynamically using'sp_execute', but the statement I need to run is far too long(apparently there is a maximum length you can pass to it), and evenbreaking it down into sub-procedures is soooooooooooooooo timeconsuming and inefficient having to format statements as strings(replacing quotes and so on)How can I use multiple tables, or indeed process HUGE procedures,withdynamic table names, or temporary tables?All answers/suggestions/questions gratefully received.Thanks
View 2 Replies
View Related
Jul 10, 2007
Hello, coming back to SQL Server after working with Oracle for a while.
I am currently using SQL Server 2005, and have an issue I am not exactly sure how to solve.
Let's say I have two instances of a database (A & B), the schema of both instances is exactly the same. If I perform an insert on instance A table A how can I automatically have that insert reflected on instance B table A? Both instance are on the same machine. Also I do not want to reflect all the data just one table across multiple instances.
I thought replication might be the answer but typically that is used across multiple machines, no?
Any help would be greatly appreciated. Thanks
View 8 Replies
View Related
Mar 15, 2004
Can you create a temporary table using an ad-hoc query?
What I am trying to do is a type of filter search (the user has this and this or this) were i will not know how may items the user is going to select until they submit....that is why i can't use a stored procedure(i think)....any help on how to do this?
Thanks,
Trey
View 8 Replies
View Related
Sep 12, 2004
Hi could anyone give me a hint what does term "temporary table" mean regarding sql server?
View 1 Replies
View Related
Nov 7, 2005
Hi all,
how can i execute this query without errors??
create table #luca(c int)
drop table #luca
select * into #luca
from anagrafica_clienti
The error lanched is:
Server: Msg 2714, Level 16, State 1, Line 6
There is already an object named '#luca' in the database.
Why if i drop the table?How can i do?Thanks guy
View 3 Replies
View Related
Jan 15, 2007
Afternoon.
I'm having trouble with a query and ASP. The query itself is easy. I need a temporary table to be filled with the contents of a select and then i need to select out of the temporary table and return the results to the ASP.
So:
Code:
DECLARE @RESULTS TABLE (
ItemID int,
ItemDescription char(50),
ItemType int,
ItemRequestedBy char(50),
ItemStatus int,
ItemQuantity int,
ItemCostPer money,
ItemOrderNumber int,
DateAdded smalldatetime,
DateLastEdited smallDateTime
)
INSERT into @results (ItemID, ItemDescription, ItemType, ItemRequestedBy, ItemStatus, ItemQuantity, ItemCostPer, ItemOrderNumber, DateAdded, DateLastEdited)
SELECT * from cr_EquipmentData
SELECT * from @results
When I run this in Query Analyser, I get exactly the results I need... But when I try and run the ASP script, I get an error about the recordset not being open. (It's not the ASP checking 'cos when I run a simple select statement it works)
I appreciate there is no use for the query as it stands, but eventually I want to be able to perform not destructive statements on the @results table before returning the data to ASP. This is more 'testing' than anything at the mo'
Has anyone got any ideas?
Thanks...
View 3 Replies
View Related
Apr 14, 2004
I am writing a stored procedure that outputs it's information to a temporary table while it assembles the information. Afterwards, it returns the contents of the temporary table as the results of the stored procedure.
I found that if you create the table, inside the SP, as an ordinary table, the information builds to that table considerably faster than if you use a true temporary table.
I found that if I create a user function that returns a table as it's return value, it is also as slow as if I used a true temporary table.
The database can amass over 2 million records in one table in just a few days. If I have the procedure query against this table, and output to an ordinary table it creates, and summarize the information it is adding to the table, then it takes an average of around 4 minutes to return the results from the query. If I change the output table to a temporary table (#temp), it between 12 and 15 minutes. Nothing else in the procedure changed. Just the kind of table. If I take the logic and move it to a function which returns those results in a RETURN table, it also takes over 14 minutes.
Why would it take so much longer outputing to a temporary table rather than a normal table? Is it because temporary tables are stored in a different database (tempdb)? Why would returning query results from a function be just as slow?
View 14 Replies
View Related
May 25, 2004
How can I view logs of local (to a session) temporary that are created/dropped?
View 6 Replies
View Related
Aug 21, 2007
Hi,
I am trying to join two tables usig two temporary tables.I want the Output as table2/table1 = Output
Select temp2.Value/temp1.Value as val
from
(
(
select count(*)as Value from [Master] m
inner join [Spares]s on s.SId=m.SID
where m.Valid_From between '2007-06-01' and '2007-06-30'
)temp1
Union
(
select isnull(sum(convert(numeric(10,0),s.Unit_Price)),'0') as Value
from [Order] h
inner join [Spares] s on s.Number = s.Number
where h.Valid_Date between '2007-06-01' and '2007-06-30'
))temp2
as t
I could not find the output..
Plz help me..
Thanks..
View 3 Replies
View Related
Nov 2, 2007
Hello,
Our java application is running on oracle and now we would like to port it to sql server 2000. In oracle we have a global temporary tables that has an option on commit to delete rows.
Now I am looking for the same option in sql server but as far as I can see sql server's local temporary tables are visible per connection. Since the connection are shared in the pool it seems I can not rely on local temporary tables since the connection does not get closed at the end of the user's session. I need something that is visible per transaction not per connection.
Is it a better approach just to create a regular table and basically have a trigger to delete all data on commit?
View 2 Replies
View Related
Jul 20, 2005
If a stored procedure invokes another stored procedure that creates atemporary table why can't the calling procedure see the temporary table?CREATE PROCEDURE dbo.GetTempASCREATE TABLE #Test([id] int not null identity,[name] as char(4))INSERT INTO #Test ([name]) VALUES ('Test')CREATE PROCEDURE dbo.TestASEXEC dbo.GetTempSELECT * FROM #Test -- Invalid object name '#Test'.Thanks,TP
View 4 Replies
View Related
Jul 20, 2005
Hi, just a quick question regarding performance and speed.Q. Run a complicated query three times or create a TEMPORARY table andaccess it as needed?I have a page where it will be accessed 10,000+ a day.In that page I have an SQL query where it involves 3 different tables(approximate table sizes T1) 200,000 T2) 900,000 T3) 20 records)I'll be running that query 3 times in that page...One to retrieve the content and display it on the page.Second to count the number of records (using COUNT(*) function)And third to retrieve the content regions. (using DISTINCT function)What would be the best way of doing...Running the SQL query 3 timesOrCreate a temporary table and access it as many time as I needRegards,
View 4 Replies
View Related
May 8, 2007
Hello,
I would like to know from other members whether they are successful in using temporary tables within a stored procedure and use that stored procedure in a report.
My scenario is like this:
I have a stored procedure A which fetches the data from different tables based on the orderno passed as input parameter.
I have built another stored procedure B with a temporary table created and inserting the rows in to this temporary table based on vendor related specifc orders by calling the above procedure A.
I have used this stored procedure in the dataset created and getting this error:
Could not generate a list of fields for the query. Check the query syntax, or click the Refresh Fields on the query toolbar.
Does anybody encountered this and have a resolution.
Thanks in advance.
View 11 Replies
View Related
Dec 12, 2007
Hi All
declare @temp table
([EVENT_TYPE_ID] [int],
[Desc] [nchar](50) NOT NULL,
[Lead_Time] [smallint] NULL)
INSERT @temp
SELECT *
FROM TBL_EVENT_DEFINiTION
The table definition for @temp is the same as TBL_EVENT_DEFINiTION. The problem is I need to add a field to the @temp table and define the values using an update statement. If I include the additional field in the @temp table declaration then I get an error saying something to the effect of the number of fields is different. Is there a way of altering the temporary table to add this field?
Many thanks in advance
Alex
View 4 Replies
View Related
May 15, 2006
Hello!
I'm creating a temporary table in a procedure to help me with some calculations. I would like the name of the temporary table to be 'dynamic', I mean, to have the hour it was created, something like this: create table #myTempTable15May11:10:00, so if someone access the procedure while it's running, he won't have problems in creating his 'own' temporary table (create table #myTempTable15May11:10:02). Is there anyway I can do this?
Thank you!
View 5 Replies
View Related
Apr 26, 2007
Hello,
I tried to make a DTS to transform data in a text file, I used a Store Procedure that use a temp table (#Resultados) but the DTS give me an error.
I read that in this case I canīt use local temp tables but I can use global temp tables, then I changed in my Store, #Resultados by ##Resultados, bu the result was the same.
My Store is likely to his. Please help me.
INSERT ##Resultados (Planta, Etapa,GrupoEquipo,Equipo,Concepto,Fecha,Guardia,
Valor,idConcepto)
EXEC CalculosDiarios @Area,@Reporte,@FechaIni,@FechaFin,0
SELECT LEFT(RP.Grupo,3) + LEFT(RP.Equipo,12) + LEFT(RP.SubGrupo,2)
+ LEFT(D.Fecha,8) + D.Valor as Dato
FROM
ReportesPlantilla RP
LEFT JOIN
##Resultados D
ON
RP.Planta = D.Planta
AND RP.Etapa = D.Etapa
AND RP.GrupoEquipo = D.GrupoEquipo
AND RP.Equipo = D.Equipo
AND RP.Concepto = D.Concepto
AND D.Fecha BETWEEN @FechaIni AND @FechaFin
View 6 Replies
View Related
Jul 23, 2007
Can some one tell me how to display the fields of temporary table in the report? In the query a global temp table is created and in the end i am displaying the fields of that table. How do i do that?
View 1 Replies
View Related
Aug 9, 2007
Hi,
I have some questions regarding Temporary tables.
I need to use a temporary table within a stored procedure (which is a transaction), should I use local temporary table or global temporary table?
If I use a temporary table in my transaction, do I destroy the temporary table at the end of the transaction, or just leave it, and let the sytem clean it up? If I destroy the temporary table at the of the transaction, what happens if another user session is accessing the temporary at the very moment?
Thanks.
Cathie
View 8 Replies
View Related
Jun 8, 2005
I am searching for information on paging large datasets, and have found
some that involve creating temporary tables in the database.
Before I head off and implement something, I have a number of issues
I'd like to bounce around here.
1. An example I found on MSDN involves creating a temporary table,
copying relevant columns to the row in the temp table. Why do
this, rather add the source tables primary keys into the temp table,
and do a join? Example; browsing Products Catalog which is
categorised into hierarchies. The MSDN version would have a temp
table created with a incrementing field which is used for the paging,
and then a number of fields are also copied from the products table to
the temp table - my question is why not simply copy the product primary
key into the temp table, and then join?
2. In real life, do people allow each user to create their own
temporary tables? If I have 1000 concurrent users, all wishing to
perform a page-based browse, I would be creating 1000 new temporary
tables. Do people consider default temp tables, that is, creating
a default temporary table for browsing each category in the products
table, for example?
3. Do you have any advice/tips for this type of problem?
Thanks!
JR.
View 17 Replies
View Related
May 1, 2000
In Access 97/2000, a local table can be created in the program database, while the data is stored in a linked database. This is useful for me to do a sort-of iterative drill-down on linked tables, e.g. filter table1 into table2, then further filter table2 into table3 and so on.....
If I do this I leave a trail that I can navigate in reverse (back up a step).
This is very important in my app.
So now my problem is....I'm trying to duplicate this in an ADP file using only ADO 2.5. I have no local tables, only server tables. If I create a temporary table, it only exists until the procedure ends.
Is there any way to create temporary tables that are specific to a user session and do not automatically delete themselves, or is there a better way to do this in SQL7?
View 1 Replies
View Related
Jan 28, 2004
on sql-server-performance.com i read :
Do not create temporary tables from within a stored procedure that is invoked by the INSERT INTO EXECUTE statement. If you do, locks on the syscolumns, sysobjects, and sysindexes tables in the TEMPDB database will be created, blocking others from using the TEMPDB database, which can significantly affect performance. [6.5, 7.0, 2000] Added 9-1-2000
I have a question does this negative effect also include simple SQL commands apart from stored procedures.
For example if from vb i execute a "Select into" temporary table. Will this have the same negative impact as with executing this from a stored procedure ?
Thank you very much
View 2 Replies
View Related
Jul 20, 2005
I have created a local temporary table (#Temp) and placed data in it.When I do:SELECT * #TempThe result is a set of rows with no columns.The SELECT statement is in the same procedure as the creation of #Temp; so Idon't believe this is a scoping issue. Does that make sense?Thank you in advance,Eric
View 3 Replies
View Related
Jan 30, 2008
hi,
I'm going through some stored procedures that have been written previously.
In every sp, they are checking for existance of temporary table in sysobjects.
So, i made a simple script and checked if #TempTable has a entry in sysobjects.
But i did not find it.
On internet many ppl are talking about checking if temp table already exists.
So my question is...
1. What are circumstances under which temporary table doesn't get deleted
automatically.
2. Does temporary table have a entry in sysobjects?
Thanks
Sandeep
View 7 Replies
View Related
Feb 26, 2007
Hi -
I have been trying to work with a data flow task that uses temporary tables on the remote DB.
I have seen Jamie Thompson's SSIS Temporary table guide, available here: http://blogs.conchango.com/jamiethomson/archive/2006/11/19/SSIS_3A00_-Using-temporary-tables.aspx, and successuflly got his download package working against my AdventureWorksDB.
I cannot get a temporary table implementation working in my SSIS package despite following JT instructions.
Current status:
Marked the OLEDB connection as retainsameconnection = true
Created a seperate execute sql task in control flow that creates the temporary table '#BUSessions'
A data flow task follows the execute sql task, the ole db source is marked a delayvalidation = true
At this point, I try to enter the query using the interface, validation kicks in and says this object is invalid. If I try to use the properties window to set sqlCommand and manually enter the query then an error icon appears on the Ole Db Source.
Can anyone help me with this?!?! I'd really appreciate it! The query provided to me (for the remote DB) uses temporary tables and I have little say in this...
p.s. - I have also ensured I manually create the global temporary table with same name before starting this process.
View 2 Replies
View Related
Apr 5, 2006
I am declaring a temp table in control flow via Execute SQL task. I then want to use that table as a source in a data task, keep it alive going back to control flow and use it as a destination in another data task following. I am having trouble just getting the first data flow to access that temp table.
In my Execute SQL task, I'm creating a simple temp table. After executing that task, I can head to the data task and change my OLE DB Source to point to that temp table, but I recieve an error about an invalid table name when I attempt to map columns or hit "OK."
Is there something else I need to do to use that temp table as a source or can I only reference it through SQL queries?
Thank you.
View 20 Replies
View Related
Mar 25, 2008
Hi,
This is my problem:
There is one table. I extracted some information on that one table and placed it in two temporary table.
Temporary Table 1
------------------------------------
ID Data 1 Data 2
1 xxxx yyyyy
2 zzzz aaaaa
3 bbbb ccccc
4 dddd eeeee
Temporary Table 2
------------------------------------
ID Data 1 Data 2
9 xxxx fffff
10 zzzz aaaaa
11 bbbb ccccc
12 dddd ggggg
Now, I want to get the only the unique values from both tables into a single table.
Temporary Table 3
------------------------------------
ID Data 1 Data 2
1 xxxx yyyyy
4 dddd eeeee
9 xxxx ffff
12 dddd ggggg
How do I do it?
Thanks!
View 1 Replies
View Related
Jul 26, 2006
Does SSIS (other than, maybe, via the Execute SQL task) support the idea of temporary tables? (I want to make a backup of production data (in temproary tables), truncate the production tables, and populate them with new data. If an error happens in the process, I'd copy the temporary backup tables back into the production tables. When the process has ended the temporary tables should "vanish")
TIA,
barkingdog
View 3 Replies
View Related