Showing posts with label queries. Show all posts
Showing posts with label queries. Show all posts

Friday, March 23, 2012

how copy table

How I make sql queries for coping one table (exist) to another table
(no exist)One method:
INSERT INTO AnotherTable
SELECT *
FROM OneTable
WHERE NOT EXISTS
(
SELECT *
FROM AnotherTable
WHERE AnotherTable.PK = OneTable.PK
)
Hope this helps.
Dan Guzman
SQL Server MVP
<f1414@.mail.ru> wrote in message
news:pje101lo8a0j5lkltd5ftuhd90ja7rmft9@.
4ax.com...
> How I make sql queries for coping one table (exist) to another table
> (no exist)|||SELECT * INTO NewTable FROM OldTable WHERE 1=1 (with data) OR WHERE 1=2
(without)
Note, that it does not transfer neither a PK,FK,indexes,Constraints
<f1414@.mail.ru> wrote in message
news:pje101lo8a0j5lkltd5ftuhd90ja7rmft9@.
4ax.com...
> How I make sql queries for coping one table (exist) to another table
> (no exist)|||SELECT *
INTO NewTable
FROM ExistingTable
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
<f1414@.mail.ru> wrote in message
news:pje101lo8a0j5lkltd5ftuhd90ja7rmft9@.
4ax.com...
> How I make sql queries for coping one table (exist) to another table
> (no exist)

Wednesday, March 7, 2012

How can i write polling and processing queries

i dont want to fully update the molap cache and i also dont want to fully read the source database that is why i am using polling query to poll the changes and processing query to get the changed records from database. for information about polling and processing query you can check the link

http://msdn2.microsoft.com/en-us/library/ms188965.aspx

but i am unable to write these queries to get all changes i.e insert, update and delete records can any one tell me how can i use these queries OR SQL Server provide some other way to just read the changes in source database not the whole dabatase.

This is

about proactive caching, right? If the changes in the table happen to be

insert, update and delete then the processing will *most probably* need to be

done fully.

When you end up with full processing, if you need to use polling notification

mechanism then the processing query is not needed. In case of deletes or

updates the polling query should fetch something like timestamp of the last

change in the database. Why not to use automatic SQL notifications?

The link you provided discusses polling and processing queries for incremental

processing. It is possible when only new records appear in the table (only

inserts).

There is one case when incremental processing can be used with "inserts,

deletes and updates". Suppose at time t1 you have a state of records S1 of

your table. Suppose you manage to make proactive caching to be scheduled at

well known time t2. I suppose Client Initiated is the only reliable one for

deterministic start of the proactive caching. If between t1 an t2 the inserts,

updates and deletes in the table do not change the records from S1 but only

create and modify incremental records then it is possible to use incremental

processing with proactive caching.



Sunday, February 19, 2012

How can i treate Huge DB size in sql server 2000

Hi all,

I have DB in operation its MDF size reached 8.38 GB and the system that work on the queries of insert timeout and the operation failed and many problems happens ...

actually the reason of the huge size of the DB is just one table that contain image field which we store word files in it in each row in the table .........

so how can i solve this problem without affecting the structure of the DB ..... coz we don't wanna to make code changes in the application that use this DB

thanks

if it 8.38 GB.. this can not be considered as a "Huge" DB from SQL Server point of view ... SQL Server handles much much larger databases... this is basically... architecture flaw... when u store word file in database it is bound to have some performance issue... its again if you have sufficient Hardware resources u can do that... you could have store the path of word file instead of file itself... anyhow, if u don't want to change the architecture... you can move the table which stores word file to a different Filegroup/disk ... or archive the unwanted data… add more hardware… etc.. etc…

Madhu

|||

I hear about the posibility of partioning the huge size table into physical partitions with out affect the logical structure so the performance of accessing the table will be faster ......

so if this process can be done on sql server 2000 on already exist DB how can it be done ...

i need an article about doing that .........

|||

If you are refering to partition of tables its supported in SQL 2005. This article might help you.

http://msdn2.microsoft.com/en-us/library/ms190787.aspx

Thanks,

|||

What about making partionning in sql server 2000?

|||

there are many article available... google it...

i think this will give some hints

http://www.microsoft.com/technet/prodtechnol/sql/2000/reskit/part10/c3861.mspx?mfr=true

regards

Madhu

|||You can create filegroups in SQL Server 2000. 8+GB is not a huge database as I have been handling databases more than 100GB and SQL Server is still functioning well. If your application is the one timing out, you have to revisit your application design and your codes as well as your database structure.|||When was the last time the database has been checked for consistency and redinexed for stats update?|||

Let me honest with that never happen ......

so .... is there any suggestions?!

|||

use DBCC DBREINDEX to reindex all the tables and use sp_updatestats to update all the table statistics and see the performance

also use sp_spaceused @.updateusage = 'TRUE' to get the space used by the data...

Madhu

How can I track the queries being issued against my sql server 2000 instance?

I have an ASP.NET app built on top of SQL Server 2000. My app is running slowly and I think I'm issuing too many queries to the database.

How can I track the queries, and when they are being issued, against my sql server 2000 instance? Is there a tool to view the queries, or is it all in a log file somewhere?

This will help me tune my ASP.NET caching strategy.

Any help is greatly appreciated!

Franco

Use SQL Server Profiler|||Choose: SQL Server, Tools, SQL Profile, File, New, Trace, Choose Server...

On the filters tab of the new window you see you can choose various filters. These include database name, application name, NT UserName, there are many to choose from.

SQL Profiler is an amazing tool for seeing whats happening "under the hood" I suggest you really read up on it in SQL Books Online as its extremely powerful.

Keep us all up to date with how you are getting on.

hth

Pace
|||Fantastic... just what I needed. Thanks!

How can I track the queries being issued against my sql server 2000 instance?

I have an ASP.NET app built on top of SQL Server 2000. My app is running slowly and I think I'm issuing too many queries to the database.

How can I track the queries, and when they are being issued, against my sql server 2000 instance? Is there a tool to view the queries, or is it all in a log file somewhere?

This will help me tune my ASP.NET caching strategy.

Any help is greatly appreciated!

Franco

Use SQL Server Profiler|||Choose: SQL Server, Tools, SQL Profile, File, New, Trace, Choose Server...

On the filters tab of the new window you see you can choose various filters. These include database name, application name, NT UserName, there are many to choose from.

SQL Profiler is an amazing tool for seeing whats happening "under the hood" I suggest you really read up on it in SQL Books Online as its extremely powerful.

Keep us all up to date with how you are getting on.

hth

Pace
|||Fantastic... just what I needed. Thanks!