Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Friday, March 30, 2012

Query help

I need to update 6 column on 1 table depending on 2 other
columns on another table (All 8 columns exists on both
tables)
here is what I am trying to write and it gives me error:
Update Table1
Set start_date = (Select start_date from Table2),
end_date = (Select end_date from Table2),
user1 = (Select user1 from Table2),
user2 = (Select user2 from Table2),
user3 = (Select user3 from Table2),
user4 = (Select user4 from Table2)
FROM Table2
Where Table2.project = Table1.project AND
Table2.Pjt_entity = Table1.Pjt_entity
Thanks for any help.
Hi,
Try this,
Update Table1
Set a.start_date = b.start_date ,
a.end_date = b.end_date,
a.user1 = b.user1,
a.user2 = b.user2,
a.user3 = b.user3,
a.user4 = b.user4
FROM Table1 a,Table2 b
Where a.project = b.project
AND a..Pjt_entity = b.Pjt_entity
Tahnks
Hari
MCDBA
"Todd" <anonymous@.discussions.microsoft.com> wrote in message
news:2d2001c486d0$5a97bdb0$a301280a@.phx.gbl...
> I need to update 6 column on 1 table depending on 2 other
> columns on another table (All 8 columns exists on both
> tables)
> here is what I am trying to write and it gives me error:
> Update Table1
> Set start_date = (Select start_date from Table2),
> end_date = (Select end_date from Table2),
> user1 = (Select user1 from Table2),
> user2 = (Select user2 from Table2),
> user3 = (Select user3 from Table2),
> user4 = (Select user4 from Table2)
> FROM Table2
> Where Table2.project = Table1.project AND
> Table2.Pjt_entity = Table1.Pjt_entity
> Thanks for any help.
|||Todd wrote:
> I need to update 6 column on 1 table depending on 2 other
> columns on another table (All 8 columns exists on both
> tables)
> here is what I am trying to write and it gives me error:
> Update Table1
> Set start_date = (Select start_date from Table2),
> end_date = (Select end_date from Table2),
> user1 = (Select user1 from Table2),
> user2 = (Select user2 from Table2),
> user3 = (Select user3 from Table2),
> user4 = (Select user4 from Table2)
> FROM Table2
> Where Table2.project = Table1.project AND
> Table2.Pjt_entity = Table1.Pjt_entity
> Thanks for any help.
Well if you have a 1:1 between the tables, you just need to specify the
column to update:
Update Table1
Set start_date = b.start_date,
end_date = b.end_date,
etc...
FROM Table2 b
Where b.project = Table1.project AND
b.Pjt_entity = Table1.Pjt_entity
David G.
|||David G. wrote:
> Todd wrote:
> Well if you have a 1:1 between the tables, you just need to specify
> the column to update:
> Update Table1
> Set start_date = b.start_date,
> end_date = b.end_date,
> etc...
> FROM Table2 b
> Where b.project = Table1.project AND
> b.Pjt_entity = Table1.Pjt_entity
Left off a table in the FROM clause. See Hari's post instead.
David G.

Query Help

Hello all, question on a query
How do I turn this into an update query?
SELECT MTE.dbo.GL10110.YEAR1, MTE.dbo.GL10110.PERIODID,
tblEdit.Acct, SUM(MTE.dbo.GL10110.DEBITAMT) - SUM(MTE.dbo.GL10110.CRDTAMNT)
AS Net
FROM tblEdit INNER JOIN
MTE.dbo.GL10110 ON tblEdit.Period =
MTE.dbo.GL10110.PERIODID AND tblEdit.Yr = MTE.dbo.GL10110.YEAR1 INNER JOIN
MTE.dbo.GL00100 ON MTE.dbo.GL10110.ACTINDX =
MTE.dbo.GL00100.ACTINDX AND tblEdit.Acct = MTE.dbo.GL00100.ACTNUMBR_1
GROUP BY MTE.dbo.GL10110.YEAR1, MTE.dbo.GL10110.PERIODID, tblEdit.Acct
ORDER BY tblEdit.Acct
I want it to update the tblEdit table. Just the DeptNet Column. just
as to what appliesHello, Brian
Because you provided such a brief description of the problem, I am only
guessing that you want one of the following (equivalent) queries:
UPDATE tblEdit SET DeptNet=(
SELECT SUM(A.DEBITAMT) - SUM(A.CRDTAMNT)
FROM MTE.dbo.GL10110 A
INNER JOIN MTE.dbo.GL00100 B
ON A.ACTINDX = B.ACTINDX
WHERE tblEdit.Period = A.PERIODID
AND tblEdit.Yr = A.YEAR1
AND tblEdit.Acct = B.ACTNUMBR_1
)
WHERE EXISTS (
SELECT * FROM MTE.dbo.GL10110 A
INNER JOIN MTE.dbo.GL00100 B
ON A.ACTINDX = B.ACTINDX
WHERE tblEdit.Period = A.PERIODID
AND tblEdit.Yr = A.YEAR1
AND tblEdit.Acct = B.ACTNUMBR_1
)
UPDATE tblEdit SET DeptNet=Net
FROM tblEdit INNER JOIN (
SELECT A.YEAR1, A.PERIODID, B.ACTNUMBR_1,
SUM(A.DEBITAMT) - SUM(A.CRDTAMNT) AS Net
FROM MTE.dbo.GL10110 A
INNER JOIN MTE.dbo.GL00100 B
ON A.ACTINDX = B.ACTINDX
GROUP BY A.YEAR1, A.PERIODID, B.ACTNUMBR_1
) x
ON tblEdit.Period = X.PERIODID
AND tblEdit.Yr = X.YEAR1
AND tblEdit.Acct = X.ACTNUMBR_1
The queries are untested, because you did not provide DDL, sample data
and expected results. See: http://www.aspfaq.com/etiquette.asp?id=5006
I assume that (Period, Yr, Acct) is a unique key in tblEdit.
The first query uses ANSI syntax; the second query uses T-SQL syntax.
Razvan

Wednesday, March 28, 2012

Query help

I need to update 6 column on 1 table depending on 2 other
columns on another table (All 8 columns exists on both
tables)
here is what I am trying to write and it gives me error:
Update Table1
Set start_date = (Select start_date from Table2),
end_date = (Select end_date from Table2),
user1 = (Select user1 from Table2),
user2 = (Select user2 from Table2),
user3 = (Select user3 from Table2),
user4 = (Select user4 from Table2)
FROM Table2
Where Table2.project = Table1.project AND
Table2.Pjt_entity = Table1.Pjt_entity
Thanks for any help.Hi,
Try this,
Update Table1
Set a.start_date = b.start_date ,
a.end_date = b.end_date,
a.user1 = b.user1,
a.user2 = b.user2,
a.user3 = b.user3,
a.user4 = b.user4
FROM Table1 a,Table2 b
Where a.project = b.project
AND a..Pjt_entity = b.Pjt_entity
Tahnks
Hari
MCDBA
"Todd" <anonymous@.discussions.microsoft.com> wrote in message
news:2d2001c486d0$5a97bdb0$a301280a@.phx.gbl...
> I need to update 6 column on 1 table depending on 2 other
> columns on another table (All 8 columns exists on both
> tables)
> here is what I am trying to write and it gives me error:
> Update Table1
> Set start_date = (Select start_date from Table2),
> end_date = (Select end_date from Table2),
> user1 = (Select user1 from Table2),
> user2 = (Select user2 from Table2),
> user3 = (Select user3 from Table2),
> user4 = (Select user4 from Table2)
> FROM Table2
> Where Table2.project = Table1.project AND
> Table2.Pjt_entity = Table1.Pjt_entity
> Thanks for any help.|||Todd wrote:
> I need to update 6 column on 1 table depending on 2 other
> columns on another table (All 8 columns exists on both
> tables)
> here is what I am trying to write and it gives me error:
> Update Table1
> Set start_date = (Select start_date from Table2),
> end_date = (Select end_date from Table2),
> user1 = (Select user1 from Table2),
> user2 = (Select user2 from Table2),
> user3 = (Select user3 from Table2),
> user4 = (Select user4 from Table2)
> FROM Table2
> Where Table2.project = Table1.project AND
> Table2.Pjt_entity = Table1.Pjt_entity
> Thanks for any help.
Well if you have a 1:1 between the tables, you just need to specify the
column to update:
Update Table1
Set start_date = b.start_date,
end_date = b.end_date,
etc...
FROM Table2 b
Where b.project = Table1.project AND
b.Pjt_entity = Table1.Pjt_entity
David G.|||David G. wrote:
> Todd wrote:
> Well if you have a 1:1 between the tables, you just need to specify
> the column to update:
> Update Table1
> Set start_date = b.start_date,
> end_date = b.end_date,
> etc...
> FROM Table2 b
> Where b.project = Table1.project AND
> b.Pjt_entity = Table1.Pjt_entity
Left off a table in the FROM clause. See Hari's post instead.
David G.

Query help

I need to update 6 column on 1 table depending on 2 other
columns on another table (All 8 columns exists on both
tables)
here is what I am trying to write and it gives me error:
Update Table1
Set start_date = (Select start_date from Table2),
end_date = (Select end_date from Table2),
user1 = (Select user1 from Table2),
user2 = (Select user2 from Table2),
user3 = (Select user3 from Table2),
user4 = (Select user4 from Table2)
FROM Table2
Where Table2.project = Table1.project AND
Table2.Pjt_entity = Table1.Pjt_entity
Thanks for any help.Hi,
Try this,
Update Table1
Set a.start_date = b.start_date ,
a.end_date = b.end_date,
a.user1 = b.user1,
a.user2 = b.user2,
a.user3 = b.user3,
a.user4 = b.user4
FROM Table1 a,Table2 b
Where a.project = b.project
AND a..Pjt_entity = b.Pjt_entity
Tahnks
Hari
MCDBA
"Todd" <anonymous@.discussions.microsoft.com> wrote in message
news:2d2001c486d0$5a97bdb0$a301280a@.phx.gbl...
> I need to update 6 column on 1 table depending on 2 other
> columns on another table (All 8 columns exists on both
> tables)
> here is what I am trying to write and it gives me error:
> Update Table1
> Set start_date = (Select start_date from Table2),
> end_date = (Select end_date from Table2),
> user1 = (Select user1 from Table2),
> user2 = (Select user2 from Table2),
> user3 = (Select user3 from Table2),
> user4 = (Select user4 from Table2)
> FROM Table2
> Where Table2.project = Table1.project AND
> Table2.Pjt_entity = Table1.Pjt_entity
> Thanks for any help.|||Todd wrote:
> I need to update 6 column on 1 table depending on 2 other
> columns on another table (All 8 columns exists on both
> tables)
> here is what I am trying to write and it gives me error:
> Update Table1
> Set start_date = (Select start_date from Table2),
> end_date = (Select end_date from Table2),
> user1 = (Select user1 from Table2),
> user2 = (Select user2 from Table2),
> user3 = (Select user3 from Table2),
> user4 = (Select user4 from Table2)
> FROM Table2
> Where Table2.project = Table1.project AND
> Table2.Pjt_entity = Table1.Pjt_entity
> Thanks for any help.
Well if you have a 1:1 between the tables, you just need to specify the
column to update:
Update Table1
Set start_date = b.start_date,
end_date = b.end_date,
etc...
FROM Table2 b
Where b.project = Table1.project AND
b.Pjt_entity = Table1.Pjt_entity
David G.|||David G. wrote:
> Todd wrote:
>> I need to update 6 column on 1 table depending on 2 other
>> columns on another table (All 8 columns exists on both
>> tables)
>> here is what I am trying to write and it gives me error:
>> Update Table1
>> Set start_date = (Select start_date from Table2),
>> end_date = (Select end_date from Table2),
>> user1 = (Select user1 from Table2),
>> user2 = (Select user2 from Table2),
>> user3 = (Select user3 from Table2),
>> user4 = (Select user4 from Table2)
>> FROM Table2
>> Where Table2.project = Table1.project AND
>> Table2.Pjt_entity = Table1.Pjt_entity
>> Thanks for any help.
> Well if you have a 1:1 between the tables, you just need to specify
> the column to update:
> Update Table1
> Set start_date = b.start_date,
> end_date = b.end_date,
> etc...
> FROM Table2 b
> Where b.project = Table1.project AND
> b.Pjt_entity = Table1.Pjt_entity
Left off a table in the FROM clause. See Hari's post instead.
--
David G.

Friday, March 23, 2012

Query for setting Cascade on Update in table relationships

Hi,

I'm looking for a query I can use to alter table relationships. What I want to do in particular, is to set every relationship to cascade on update. Can anyone point me out to a solution? MSDN seems very vague in this subject.

Thanks,
Tiago

Write queries to drop the constraints and recreate them with the appropiate settings.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

This is not a data access question. Maybe you can put the question on SQL Server/TSQL forum

query for row creation/last update

I'm working on a database migration. The destination DB has date fields in each table for row creation and last update the source DB does not. Is there a system table or way to query the transaction long to find the entry date and last update date for a row using the primary key in the source DB?

Thanks for any helpThere is no builtin audit function for that. The typical audit is to create a trigger and keep track of your insert/update/delete.

Monday, March 12, 2012

Query doesnt find existing data

SQL Server 2000 Enterprise

While testing an update script I found that a number of data rows are inaccessible using my query, though the data does exist in the table. I can browse records to find the data or query the record by some column names, but not by others.

For example:

SELECT name FROM tblPersonalInformation WHERE [ID Number] = 2358899;

would not find the data sought. However, if I put in:

SELECT address FROM tblPersonalInformation WHERE name = Doe, John;

the query yields the desired data. Many of the records queried display the specified data with no problem. I have found this problem to exist on a number of data rows, but cant figure out a reason. The front-end application displays the data without any apparent problems.

Ideas please.On the surface, it doesn't seem plausable...

Post the DDL of the Table, so we can see...|||Service pack #?|||Trailing spaces, perhaps?

What is the datatype of [ID Number]?|||Do this and let us know what you get:

select * from tblPersonalInformation where charindex(char(160), [ID Number]) > 0|||I have seen corrupt indexes cause this. Try

dbcc dbreindex ('tblPersonalInformation')

Query doesnt find existing data

SQL Server 2000 Enterprise

While testing an update script I found that a number of data rows are inaccessible using my query, though the data does exist in the table. I can browse records to find the data or query the record by some column names, but not by others.

For example:

SELECT name FROM tblPersonalInformation WHERE [ID Number] = 2358899;

would not find the data sought. However, if I put in:

SELECT address FROM tblPersonalInformation WHERE name = Doe, John;

the query yields the desired data. Many of the records queried display the specified data with no problem. I have found this problem to exist on a number of data rows, but cant figure out a reason. The front-end application displays the data without any apparent problems.

Ideas please.What is the datatype of [ID Number]?

Monday, February 20, 2012

Query and process performace with incremental update

hello all,

we are working on a project with a large scale of data (around 1000 rows per second).
we built a cube on this fact table.

this table will hold at most 90M rows.

we need the data in the cube to be "real time", that mean, up to date.

we are doing it by proactive caching- incremental update.

we also need a very good query performance.

that's why the storage mode is set to MOLAP.

we still get a low performace from the cube process and and the querys.

any suggestions how to solve this issues?

Thanks in advance,

Shy Engelberg - Certagon.

You might be seeing the results of the meta data locking (see http://geekswithblogs.net/darrengosbell/archive/2007/04/24/SSAS-Processing-ForceCommitTimeout-and-quotthe-operation-has-been-cancelledquot.aspx) If you are processing the cube very frequently. You probably need to profile the server to gather as much information as you can to figure out where the issues are.

Is it on the source system - selected only new records?

Is the system CPU, IO or memory bound?

Are you using partitions to isolate the processing to a smaller subset of the data?

|||

The SSAS 2005 Performance Guide is a good reference for these kinds of issues ( http://download.microsoft.com/download/8/5/e/85eea4fa-b3bb-4426-97d0-7f7151b2011c/SSAS2005PerfGuide.doc).

I agree with Darren's idea of identifying whether the problem is occuring in retreiving source data records or in assembling the MOLAP structures. And partitioning may also be beneficial if you can isolate updates to a smaller partition.

You may also want to consider using HOLAP. HOLAP will give you excellent query performance for most queries with shorter processing times.

Bryan