|
Hi
How can we can make DB2 and SQL server communicate with each other. It's not a kind of datamigration, these were need to be updating each other on regular basis.
Thanking u in advance,
Regards,
Ajit
-- modified at 0:51 Thursday 8th March, 2007
|
|
|
|
|
I have a service (which I have written in C#) that I want to run on 2 different computers however they will both be accessing the same database.
Is there a way to tell when one computer is writing to the database so I can stop the other from writing to it at the same time to avoid contention issues?
|
|
|
|
|
It would help to know what kind of database... Access, SQL Server, ...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
In that case, no, you don't have to worry about it. SQL Server maintains order on its own. Just keep in mind that the "last write" will win.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
sql server 2000
server is MyServer named "SALE" and is on local comp
When stored procedure is like this
UPDATE MyServer.MyDataBase.dbo.Mytable SET System='pib'
there is an error 7405
:"Heterogeneous queries require the ANSI_NULLS and Ansi_Warnings option to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query."
Coulmn System is db type varchar(50)
When stored procedure is like this
UPDATE MyDataBase.dbo.Mytable SET System='pib' it is all ok
Problem is that I need to be remote MyServer.MyDataBase.dbo.Mytable...
It is all working when is sent from QueryAnalizer
Where and how can i resolve this
|
|
|
|
|
SET ANSI_NULLS ON
SET ANSI_WARNINGS ON
GO CREATE PROCEDURE spStoredProdc AS ... go
SET ANSI_NULLS OFF
SET ANSI_WARNINGS OFF
|
|
|
|
|
I've been trying to consolidate/reuse some business logic in a recent project and doing so would require me (within a MS-SQL 2000 stored procedure) to get a dataset from a stored procedure and aggregate some data. Is there a way to get a dataset from a stored procedure and put it in a temporary table? This is not an output variable, just the regular output dataset. I'm using Microsoft SQL 2000.
Help please!
USE PD9
DECLARE @RC int
DECLARE @datebegin varchar(10)
DECLARE @dateend varchar(10)
SET @datebegin = '01/01/2007'
SET @dateend = '01/15/2007'
--this is a dataset of our sales reps
DECLARE sales_cursor CURSOR
FOR
SELECT DISTINCT
[ABAN8]
FROM
[vF0101_RepDetails]
ORDER BY [ABAN8]
OPEN sales_cursor
DECLARE @an8 int
FETCH NEXT FROM sales_cursor INTO @an8
WHILE (@@FETCH_STATUS <> -1)
BEGIN
IF (@@FETCH_STATUS <> -2)
BEGIN
-- i'm looping through a dataset of our sales reps
-- now i need to get a dataset from the below sproc
-- loop through that dataset and put it in a temp table
-- the problem is getting the dataset from the next line - HOW??
-- EXEC @RC = [PD9].[dbo].[usp_rs_getSalesShipments] @an8, @datebegin, @dateend
-- print @RC
END
FETCH NEXT FROM sales_cursor INTO @an8
END
CLOSE sales_cursor
DEALLOCATE sales_cursor
|
|
|
|
|
You can use:
INSERT INTO #MyTempTable (col1, col2, col3, ..., coln)
EXEC MyStoredProc where the temporary table's column list matches the columns returned in the stored procedures resultset (and their data types).
|
|
|
|
|
hi
plzz tell me, if any one use split function in sql server 2000
i want to split one column data and then get coresponding values from another table like:-
table_1
year code
2001 1,2,6
2002 2,5,6
table_2
code name
1 one
2 two
5 five
6 six
i want to split code on(,)but this query is not working.
"select name from table_2 where code=(split(select code from table_1 where year='2001'))"
plzz help me
thanks in advance
john
-- modified at 11:16 Wednesday 7th March, 2007
|
|
|
|
|
|
Hi,
I know how to retrieve data from SQL to Dataset. Can anyone help me on how to insert updated data from Dataset back to SQL.
Thanks
Raj
|
|
|
|
|
From VS 2005 documentation:
DataAdapter.Update - Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataSet from a DataTable named "Table."
|
|
|
|
|
Thanks for your reply. "DataAdapter.Update" is for updating a DataTable in DataSet. I want to know how to insert this updated data back to SQL.
|
|
|
|
|
Try this snippet and let me know if it worked for you.
SqlConnection c = new SqlConnection(@"Data Source=(local)\SQL2005;Initial Catalog=TEST_DB;Integrated Security=True");<br />
SqlDataAdapter da = new SqlDataAdapter("select * from customer where customer_id = 1", c);<br />
SqlCommandBuilder cb = new SqlCommandBuilder(da);<br />
DataTable dt = new DataTable();<br />
<br />
da.Fill(dt);<br />
dt.Rows[0]["NAME"] = dt.Rows[0]["NAME"].ToString() + "1";<br />
da.Update(dt);
|
|
|
|
|
hi U have to use commandbuilder(dataadapterobject)
|
|
|
|
|
Hi
I have problem in getting primary and foreign key for a given table.
For example in a Adventureworks Database, Production.ProductCostHistory table.
If i try to get the foreign key related table it is not returning any value.
But ProductID is is both primary and foreign key.
How to get the foreign key table for the given table.
sp_fkeys not working if it is a composite key.
exec sp_fkeys @PKTable_name='ProductCostHistory',@PKTable_Owner='Production'
Can any one help me please?........
kesavan
|
|
|
|
|
If you have the correct rights you can select your table from sysobjects where [name] = 'yourtablename'
You can use the id from that table to look in sysindexes for your primary keys.
Then you can look in sysforeignkeys to see if you have some foreignkeys
Hope that helps.
Ben
|
|
|
|
|
can you give me any sample example for a column, it is both primary and foreign key please.
kesavan
|
|
|
|
|
It is not that easy.
First if you look in the sysobjects table for your table name to get the id.
Next if you look in the sysobjects table for an xtype = 'PK' that is a primary key that has a parent_obj = the id you found above. This gives you your primary key
Next you look in the sysforeignkeys table using the parentid
joined back to sysobjects to try and find a foreignkey if it exists.
So if you have a customer table and a customertype table
Customer Table:
customerId
CustomertypeId
... other stuff
CustomerType Table:
customertypeId
... other stuff
Here's a query:
declare @id int
select @id = id from sysobjects where [name] = 'customertype'
select * from sysobjects where xtype = 'pk' and parent_obj = @id
select * from sysforeignkeys fk
join sysobjects so on fk.fkeyid = so.parent_obj and so.xtype = 'f'
where fk.rkeyid = @id
I don't know if that helps at all it is quite complicated.
Ben
|
|
|
|
|
Thanks a lot ben
I have done this by following way
Select Tab1.Column_name,(select Schema_name(uid) from sys.sysobjects where id=PK_table_id)+'.'+Tab2.PKtable_name as PKTable_name, Tab2.PKColumn_name, Tab1.Table_Schema+'.'+Tab2.FKTable_Name as FKTable_Name, Tab2.FKColumn_Name from (Select Column_Name, Data_Type, Table_Schema from Information_schema.columns where Table_Name='Product' and Table_Schema='Production') Tab1 left outer join (select PKColumn_Name=c1.name,PKTable_Name=Convert(Sysname,Object_Name(f.refereced_Object_id)),PKTable_ID=f.referenced_Object_id,FKTable_Name=o1.name,FKColumn_Name=c2.name from sys.all_objects o1, sys.all_objects o2, sys.all_columns c1, sys.all_column c2, sys.foreign_keys f inner join sys.foreign_key_column k on(k.constraint_object_id=f.object_id) inner join sys.indexes i on (f.referenced_object_id=i.object_id and f.key_index_id=i.index_id) where o1.object_id=f.parent_object_id and o1.object_id=object_id('production.product') and o2.object_id=f.parent_object_id and c1.object_id=f.referenced_object_id and c2.object_id=f.parent_object_id and c1.column_id=k.referenced_column_id and c2.column_id=k.parent_column_id) Tab2 on Tab1.Column_name=Tab2.FKColumn_name
kesavan
|
|
|
|
|
Hi!
How can one get a list of all the tables in an Access database using a query? ...I'm interested in something similar in effect to the SHOW TABLES in MySql.
Thanks.
|
|
|
|
|
|
I 've got a textbox which has to accept only numeric values..do i use the regularexpression validator(if so how?)
karabo mekgwe
Ecom Institute
|
|
|
|
|
wrote: do i use the regularexpression validator(if so how?)
You can do. Off the top of my head the regular expression would be something like
^[0-9]*$
NOTE: This accepts only positive integers only.
|
|
|
|