Showing posts with label querry. Show all posts
Showing posts with label querry. Show all posts

Tuesday, March 20, 2012

Problem with select into querry

I have two database on same server. I want write a querry,witch qering the data from 1st database, than create a new table on the 2nd database.

But the in clause after the into clause permanently generate error.

Here is the query’s little part:

Select …..

into Backup in ’Test.mdb’ from …

I try wrote other ways

in ’Test’

in ’dbo.Test’

in dbo.Test

but none of them work

its only work, when i not want pass for the second database

How can i pass the result for the 2nd Database

What database engine are you using? You're posting this in the MS SQL forum, yet I see the "Test.mdb" which looks like an Access database.

If it's MS SQL, use the syntax like:

SELECT ... INTO SERVER2.DBname.dbo.TableName

You will also need to add SERVER2 as a linked server to SERVER1 (read BOL on sp_addlinkedserver).

|||

May you post your complete SQL Statement? Perhaps you have an syntax mistake (I never user into to query a access-database).

ralph

|||

I use MS SQL 2005

here the query, sorry the column names is hungarian

the server name is sysnapsys and synapsys have the two database

select

t1a.azonosító,

t1a.nv,

t1a.lakcím_irsz,

t1a.lakcím_helysg,

t1a.lakcím_uhea,

t1a.szlacím_nv,

t1a.szlacím_irsz,

t1a.szlacím_helysg,

t1a.szlacím_uhea,

t3.telepíts_id?pontja,

t4.szerzodes_megszunt_idopont,

t9.befizetett_eloleg,

t9.havi_díj_fizetsi_mód

into SzerzWorth

from t0, t1a, t3, t4, t9

where t0.t1a_id = t1a.idn and t0.t4_id = t4.idn

and t0.t9_id = t9.idn and t0.t3_id = t3.idn

this querry is working. If i want add the in clause after the "into SzerzWorth", then the server throw me an error. I try this methods:

" into SzerzWorth in 'Teszt' "

" into SzerzWorth in 'dbo.Teszt' "

" into SzerzWorth in 'synapsys.Teszt' "

" into SzerzWorth in 'synapsys.db.Teszt' "

but permanently throw me the error:

"Msg 156, Level 15, State 1, Line 15

Incorrect syntax near the keyword 'in'. "

|||I posted above|||hi mr. saint,

a SELECT INTO <table> IN is not a correct syntax. The IN keyword expects a list(s) of values e.g: IN (1, 2, 3) and usually used in WHERE clauses to check for data w/c matches the lists in IN.i.e.: SELECT * FROM table WHERE field1 IN (n1, n2.. n2n).. the query should be:

SELECT <fields>
INTO SzerzWorth
FROM t0, t1a, t4, t9

INSERT INTO synapsys.db.Teszt (fields...)
SELECT fields..
FROM SzerzWorth

or. simply:
INSERT INTO sysnapsys.db.Teszt(fields..)
SELECT <fields>
FROM t0, t1a, t4, t9

HTH|||I don′t know if that is the problem, but as I never use umlauts or special characters in the object names you should put the names in brackets, because the syntax look quite ok:

select

t1a.[azonosító],

t1a.[nv],

t1a.[lakcím_irsz],

t1a.[lakcím_helysg],

t1a.lakcím_uhea,

t1a.[szlacím_nv],

t1a.[szlacím_irsz],

t1a.[szlacím_helysg],

t1a.[szlacím_uhea],

t3.[telepíts_id?pontja],

t4.[szerzodes_megszunt_idopont],

t9.[befizetett_eloleg],

t9.[havi_díj_fizetsi_mód]

into SzerzWorth

from t0, t1a, t3, t4, t9

where t0.t1a_id = t1a.idn and t0.t4_id = t4.idn

and t0.t9_id = t9.idn and t0.t3_id = t3.idn

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de

Saturday, February 25, 2012

Problem with querry performance locally vs. network

Hi,

I work on speed-up our company SQL Server 2000. I reconstructed one querry and test it on client computer (other than server). There was no profit. I was surprised :(. I supposed several times speed-up. Next I run old and new querry directly on our SQL Server machine. The result was proper - new (after modifications) querry takes 2,5 times less time than previous.

Ok, question: why there wasn't profit of modification from client computer?

I thougth that reason is slow network. So I copy from client computer file of weight 80MB to server. This takes 10seconds. Result of my querry is 35MB and it takes 17 seconds on client computer and 6 seconds directly from server.

Best regards,
Walter Luszczyk

If the result of your query is 35MB in size then it's not particularly surprising that it takes 6 seconds for the client computer to get the results. Likely the reason it's taking longer when you copy the file to the client is that the client computer does not perform as well as the server. After your tuning, the server processed the query faster but it still had to transfer 35MB of data over the LAN.

Consider your 80MB data file. How long did it take for you do copy it from the server to the client?

With this in mind, you should consider whether you need 35MB worth of results. This is 43% of your database.

Can you work with less columns?|||

Unfortunately I cannot select smaller result - it's report ... :(

I try bit this problem from another side and my observations are:

I use SQL Profiler to solve the problem. Sending old querry yields performance: CPU:8641, Reads: 10688, Writes: 0, Duration: 12513. But new querry yields: CPU: 627, Reads: 10627, Writes: 0, Duration: 11956.

So why duration doesn't change (12513 : 11956) while CPU changes a lot (8641 : 627)?

This time result's size is only 7MB - it's really small in out network.

Regards,

Walter

|||

Duration in Profiler is not necessarily a measure of time to execute the query. It actually a measure of the time it takes to execute the query, get the result to the client, and the client to close the recordset.

For example, if you're transferring megabytes of data and your client is on a gigabit ethernet connection, your duration will be lower than if your client is on a 10 megabit ethernet connection. If you can set up a VPN connection between your client and server (connect from home) then you would see an even longer duration.

I've actually seen Microsoft Access tables opened on SQL Server that showed durations of 20-30 minutes but showed very low reads and CPU.

In your case, you need to either reduce the size of the data being returned or get a higher bandwidth connection to your server.

Some ideas:

Reduce the size of the data types. For example: Are you using nvarchar where you could use VarChar? Can you convert the output of your DateTime columns to SmallDateType?