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

Wednesday, March 28, 2012

Saving Queries

I just started using Visual Studio 2005. How do you actually save your queries to use again? Also, is there a way to export results in a user friendly format?

thanks!

Not quite sure what you mean.

Your queries are saved in the report solution as part of the dataset - or do you mean that you want to use a report template that contains certain query-based datasets that you often re-use ?

|||

I open VS 2005

Connect to SQL Server 05

Go to Data - new query

write query

run for results

How do I save this query to be used again?

I tried sacing as a project but when I re-open the query is gone.

Also, can I only copy and paste the results or can I eport as .csv etc..?

thanks

|||

You can use storedproc for this. Insted of queries create it as a storedproc and you can call it from the report by choosing thype as storedproc.

As for export, if you are using VS2005 you have a save icon that will export your report to a bunch of formats including excel,csv PDF,etc..

|||

You say you "open VS 2005" but you don't say what type of project you're in. (And before you say anything yes I agree this is totally wacked but this is how it works).

Make sure you're in a data project. If you don't have a data project in your solution add one. You should find it under Projects of Type Other. (don't ask me)

When you choose a New Project of Database type, if I remember correctly, you will be asked to add some database connections. You can always add more later. This is pretty much the "connect to sql server 2005" step, and, in the Solution Explorer, you will see some items under your project called Database References that look like what you see in the Server Explorer.

You will also see some folders which have been created under this Project folder for storage of various types of scripts and queries. YOu don't have to use this organization, but it's the way they set it up by default.

Try right-clicking on the name of your Data project in the Solution Explorer and choose to Add New Item... etc. You will see what you have been looking for on that context menu, I think.

>L<

|||

I do not see what you have listed.

I connected to te server.

I go to data - new query

Create the query but cannot save it for re-use?

I do not see this

- Make sure you're in a data project. If you don't have a data project in your solution add one. You should find it under Projects of Type Other. (don't ask me)

|||

You said you were in Visual Studio, right?

So... let me guess: you're actually in Visual Studio Express?

So you don't see a new project of Data type. OK.

Are you in the Web version or the VB version of Express?

First of all: you can *always* add a file of type Text and then save the SQL out of the SQL pane and add it to a text file in the project. Next time you want to do a New Query you can copy the SQL back into the SQL pane of the query designer.

In the Express version, though, you don't have solutions, you just have projects (of the requisite type: web site or VB or whatever).

In the project, the way you attach a "sense" of data, therefore, is not to associate a project of data type. Instead, you create an item of type "new dataset". In the dataset information, you specify the data connection and you write the query. The dataset is persisted along with information about how it receives its data (sometimes a query, sometimes a stored procedure or whatever).

This is the best I can do to explain. And you've kind of written to the wrong forum... hope it helps anyway.

>L<

saving output from multiple queries

Greetings,
I have what seems a simple problem...
I want to save the output from the following queries in 1 file in
'SQL Query Analyser', but I can only save each 'grid' separately.
I have about 30 queries in total. 'Messages' tells me the number of
rows affected but I need the data.
So can I save all the grids together at the same time in 1 file ?
Thanks
Mike
PRINT 'HEAT 3510'
SELECT f.persfirstname AS First_Name,
f.perslastname AS Last_Name,
a.rsrchqnumber AS Personal_nr,
b.asgtassignmentid AS Contract_nr,
ISNULL(c.tishcode,'') AS TS_Id,
ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,
d.tpitdaydate AS Payroll_Date,
c.tishactualenddate AS TS_end_date
FROM resources a
INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
INNER join timesheets c ON c.tishasgtguid = b.asgtguid
INNER join users e ON e.userguid = a.rsrcuserguid
INNER join persons f ON e.userpersguid = f.persguid
LEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguid
WHERE a.rsrchqnumber = 80000147
and b.asgtassignmentid = 0000001234
and c.tishactualenddate > '20050614'
and (d.tpitdaydate > '20050614'
or d.tpitdaydate IS null)
order by d.tpitdaydate
SELECT f.persfirstname AS First_Name,
f.perslastname AS Last_Name,
a.rsrchqnumber AS Personal_nr,
b.asgtassignmentid AS Contract_nr,
ISNULL(c.tishcode,'') AS TS_Id,
c.tishactualenddate AS TS_end_date,
g.thisdaydate AS TSH_date
FROM resources a
INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
INNER join timesheets c ON c.tishasgtguid = b.asgtguid
INNER join users e ON e.userguid = a.rsrcuserguid
INNER join persons f ON e.userpersguid = f.persguid
INNER join timesheethistory g ON g.thistishguid = c.tishguid
WHERE a.rsrchqnumber = 80000147
and b.asgtassignmentid = 0000001234
and c.tishactualenddate > '20050619'
order by g.thisdaydate
PRINT 'HEAT 3213'
Hi
1) DTS
2) BCP
<michaelnewport@.yahoo.com> wrote in message
news:1126768676.888961.311210@.g14g2000cwa.googlegr oups.com...
> Greetings,
> I have what seems a simple problem...
> I want to save the output from the following queries in 1 file in
> 'SQL Query Analyser', but I can only save each 'grid' separately.
> I have about 30 queries in total. 'Messages' tells me the number of
> rows affected but I need the data.
> So can I save all the grids together at the same time in 1 file ?
> Thanks
> Mike
> PRINT 'HEAT 3510'
> SELECT f.persfirstname AS First_Name,
> f.perslastname AS Last_Name,
> a.rsrchqnumber AS Personal_nr,
> b.asgtassignmentid AS Contract_nr,
> ISNULL(c.tishcode,'') AS TS_Id,
> ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,
> d.tpitdaydate AS Payroll_Date,
> c.tishactualenddate AS TS_end_date
> FROM resources a
> INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
> INNER join timesheets c ON c.tishasgtguid = b.asgtguid
> INNER join users e ON e.userguid = a.rsrcuserguid
> INNER join persons f ON e.userpersguid = f.persguid
> LEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguid
> WHERE a.rsrchqnumber = 80000147
> and b.asgtassignmentid = 0000001234
> and c.tishactualenddate > '20050614'
> and (d.tpitdaydate > '20050614'
> or d.tpitdaydate IS null)
> order by d.tpitdaydate
> SELECT f.persfirstname AS First_Name,
> f.perslastname AS Last_Name,
> a.rsrchqnumber AS Personal_nr,
> b.asgtassignmentid AS Contract_nr,
> ISNULL(c.tishcode,'') AS TS_Id,
> c.tishactualenddate AS TS_end_date,
> g.thisdaydate AS TSH_date
> FROM resources a
> INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
> INNER join timesheets c ON c.tishasgtguid = b.asgtguid
> INNER join users e ON e.userguid = a.rsrcuserguid
> INNER join persons f ON e.userpersguid = f.persguid
> INNER join timesheethistory g ON g.thistishguid = c.tishguid
> WHERE a.rsrchqnumber = 80000147
> and b.asgtassignmentid = 0000001234
> and c.tishactualenddate > '20050619'
> order by g.thisdaydate
> PRINT 'HEAT 3213'
>
|||Hi,
I have faced this problem just a month before.
u can do on thing
u can make 30 tables and tranfer the data to access database and carry
that access database anywhere .
in BCP file u have to maintain a lot.
in access u can create the table and keep on inserting in it.
hope that helps u
from
Doller
sql

saving output from multiple queries

Greetings,

I have what seems a simple problem...
I want to save the output from the following queries in 1 file in
'SQL Query Analyser', but I can only save each 'grid' separately.
I have about 30 queries in total. 'Messages' tells me the number of
rows affected but I need the data.

So can I save all the grids together at the same time in 1 file ?

Thanks
Mike

PRINT 'HEAT 3510'

SELECT f.persfirstname AS First_Name,
f.perslastname AS Last_Name,
a.rsrchqnumber AS Personal_nr,
b.asgtassignmentid AS Contract_nr,
ISNULL(c.tishcode,'') AS TS_Id,
ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,
d.tpitdaydate AS Payroll_Date,
c.tishactualenddate AS TS_end_date
FROM resources a
INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
INNER join timesheets c ON c.tishasgtguid = b.asgtguid
INNER join users e ON e.userguid = a.rsrcuserguid
INNER join persons f ON e.userpersguid = f.persguid
LEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguid
WHERE a.rsrchqnumber = 80000147
and b.asgtassignmentid = 0000001234
and c.tishactualenddate > '20050614'
and (d.tpitdaydate > '20050614'
or d.tpitdaydate IS null)
order by d.tpitdaydate

SELECT f.persfirstname AS First_Name,
f.perslastname AS Last_Name,
a.rsrchqnumber AS Personal_nr,
b.asgtassignmentid AS Contract_nr,
ISNULL(c.tishcode,'') AS TS_Id,
c.tishactualenddate AS TS_end_date,
g.thisdaydate AS TSH_date
FROM resources a
INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
INNER join timesheets c ON c.tishasgtguid = b.asgtguid
INNER join users e ON e.userguid = a.rsrcuserguid
INNER join persons f ON e.userpersguid = f.persguid
INNER join timesheethistory g ON g.thistishguid = c.tishguid
WHERE a.rsrchqnumber = 80000147
and b.asgtassignmentid = 0000001234
and c.tishactualenddate > '20050619'
order by g.thisdaydate

PRINT 'HEAT 3213'Try the Query menu: Results to File (or Results to Text).

Simon|||You can save it to one file .
there may be a menutitle at sql query analyser
that is named something like "Query"
in there you have the option to select how you want your
result.
there you can select, that you get results in a file.
by starting the queries you will be asked where to save
the file.

> Greetings,
> I have what seems a simple problem...
> I want to save the output from the following queries in 1 file in
> 'SQL Query Analyser', but I can only save each 'grid' separately.
> I have about 30 queries in total. 'Messages' tells me the number of
> rows affected but I need the data.
> So can I save all the grids together at the same time in 1 file ?
> Thanks
> Mike
> PRINT 'HEAT 3510'
> SELECT f.persfirstname AS First_Name,
> f.perslastname AS Last_Name,
> a.rsrchqnumber AS Personal_nr,
> b.asgtassignmentid AS Contract_nr,
> ISNULL(c.tishcode,'') AS TS_Id,
> ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,
> d.tpitdaydate AS Payroll_Date,
> c.tishactualenddate AS TS_end_date
> FROM resources a
> INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
> INNER join timesheets c ON c.tishasgtguid = b.asgtguid
> INNER join users e ON e.userguid = a.rsrcuserguid
> INNER join persons f ON e.userpersguid = f.persguid
> LEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguid
> WHERE a.rsrchqnumber = 80000147
> and b.asgtassignmentid = 0000001234
> and c.tishactualenddate > '20050614'
> and (d.tpitdaydate > '20050614'
> or d.tpitdaydate IS null)
> order by d.tpitdaydate
> SELECT f.persfirstname AS First_Name,
> f.perslastname AS Last_Name,
> a.rsrchqnumber AS Personal_nr,
> b.asgtassignmentid AS Contract_nr,
> ISNULL(c.tishcode,'') AS TS_Id,
> c.tishactualenddate AS TS_end_date,
> g.thisdaydate AS TSH_date
> FROM resources a
> INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
> INNER join timesheets c ON c.tishasgtguid = b.asgtguid
> INNER join users e ON e.userguid = a.rsrcuserguid
> INNER join persons f ON e.userpersguid = f.persguid
> INNER join timesheethistory g ON g.thistishguid = c.tishguid
> WHERE a.rsrchqnumber = 80000147
> and b.asgtassignmentid = 0000001234
> and c.tishactualenddate > '20050619'
> order by g.thisdaydate
> PRINT 'HEAT 3213'|||Simon Hayes schreef:

> Try the Query menu: Results to File (or Results to Text).
> Simon

purrfect !

saving output from multiple queries

Greetings,
I have what seems a simple problem...
I want to save the output from the following queries in 1 file in
'SQL Query Analyser', but I can only save each 'grid' separately.
I have about 30 queries in total. 'Messages' tells me the number of
rows affected but I need the data.
So can I save all the grids together at the same time in 1 file ?
Thanks
Mike
PRINT 'HEAT 3510'
SELECT f.persfirstname AS First_Name,
f.perslastname AS Last_Name,
a.rsrchqnumber AS Personal_nr,
b.asgtassignmentid AS Contract_nr,
ISNULL(c.tishcode,'') AS TS_Id,
ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,
d.tpitdaydate AS Payroll_Date,
c.tishactualenddate AS TS_end_date
FROM resources a
INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
INNER join timesheets c ON c.tishasgtguid = b.asgtguid
INNER join users e ON e.userguid = a.rsrcuserguid
INNER join persons f ON e.userpersguid = f.persguid
LEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguid
WHERE a.rsrchqnumber = 80000147
and b.asgtassignmentid = 0000001234
and c.tishactualenddate > '20050614'
and (d.tpitdaydate > '20050614'
or d.tpitdaydate IS null)
order by d.tpitdaydate
SELECT f.persfirstname AS First_Name,
f.perslastname AS Last_Name,
a.rsrchqnumber AS Personal_nr,
b.asgtassignmentid AS Contract_nr,
ISNULL(c.tishcode,'') AS TS_Id,
c.tishactualenddate AS TS_end_date,
g.thisdaydate AS TSH_date
FROM resources a
INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
INNER join timesheets c ON c.tishasgtguid = b.asgtguid
INNER join users e ON e.userguid = a.rsrcuserguid
INNER join persons f ON e.userpersguid = f.persguid
INNER join timesheethistory g ON g.thistishguid = c.tishguid
WHERE a.rsrchqnumber = 80000147
and b.asgtassignmentid = 0000001234
and c.tishactualenddate > '20050619'
order by g.thisdaydate
PRINT 'HEAT 3213'Hi
1) DTS
2) BCP
<michaelnewport@.yahoo.com> wrote in message
news:1126768676.888961.311210@.g14g2000cwa.googlegroups.com...
> Greetings,
> I have what seems a simple problem...
> I want to save the output from the following queries in 1 file in
> 'SQL Query Analyser', but I can only save each 'grid' separately.
> I have about 30 queries in total. 'Messages' tells me the number of
> rows affected but I need the data.
> So can I save all the grids together at the same time in 1 file ?
> Thanks
> Mike
> PRINT 'HEAT 3510'
> SELECT f.persfirstname AS First_Name,
> f.perslastname AS Last_Name,
> a.rsrchqnumber AS Personal_nr,
> b.asgtassignmentid AS Contract_nr,
> ISNULL(c.tishcode,'') AS TS_Id,
> ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,
> d.tpitdaydate AS Payroll_Date,
> c.tishactualenddate AS TS_end_date
> FROM resources a
> INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
> INNER join timesheets c ON c.tishasgtguid = b.asgtguid
> INNER join users e ON e.userguid = a.rsrcuserguid
> INNER join persons f ON e.userpersguid = f.persguid
> LEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguid
> WHERE a.rsrchqnumber = 80000147
> and b.asgtassignmentid = 0000001234
> and c.tishactualenddate > '20050614'
> and (d.tpitdaydate > '20050614'
> or d.tpitdaydate IS null)
> order by d.tpitdaydate
> SELECT f.persfirstname AS First_Name,
> f.perslastname AS Last_Name,
> a.rsrchqnumber AS Personal_nr,
> b.asgtassignmentid AS Contract_nr,
> ISNULL(c.tishcode,'') AS TS_Id,
> c.tishactualenddate AS TS_end_date,
> g.thisdaydate AS TSH_date
> FROM resources a
> INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
> INNER join timesheets c ON c.tishasgtguid = b.asgtguid
> INNER join users e ON e.userguid = a.rsrcuserguid
> INNER join persons f ON e.userpersguid = f.persguid
> INNER join timesheethistory g ON g.thistishguid = c.tishguid
> WHERE a.rsrchqnumber = 80000147
> and b.asgtassignmentid = 0000001234
> and c.tishactualenddate > '20050619'
> order by g.thisdaydate
> PRINT 'HEAT 3213'
>|||Hi,
I have faced this problem just a month before.
u can do on thing
u can make 30 tables and tranfer the data to access database and carry
that access database anywhere .
in BCP file u have to maintain a lot.
in access u can create the table and keep on inserting in it.
hope that helps u
from
Doller

saving output from multiple queries

Greetings,
I have what seems a simple problem...
I want to save the output from the following queries in 1 file in
'SQL Query Analyser', but I can only save each 'grid' separately.
I have about 30 queries in total. 'Messages' tells me the number of
rows affected but I need the data.
So can I save all the grids together at the same time in 1 file ?
Thanks
Mike
PRINT 'HEAT 3510'
SELECT f.persfirstname AS First_Name,
f.perslastname AS Last_Name,
a.rsrchqnumber AS Personal_nr,
b.asgtassignmentid AS Contract_nr,
ISNULL(c.tishcode,'') AS TS_Id,
ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,
d.tpitdaydate AS Payroll_Date,
c.tishactualenddate AS TS_end_date
FROM resources a
INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
INNER join timesheets c ON c.tishasgtguid = b.asgtguid
INNER join users e ON e.userguid = a.rsrcuserguid
INNER join persons f ON e.userpersguid = f.persguid
LEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguid
WHERE a.rsrchqnumber = 80000147
and b.asgtassignmentid = 0000001234
and c.tishactualenddate > '20050614'
and (d.tpitdaydate > '20050614'
or d.tpitdaydate IS null)
order by d.tpitdaydate
SELECT f.persfirstname AS First_Name,
f.perslastname AS Last_Name,
a.rsrchqnumber AS Personal_nr,
b.asgtassignmentid AS Contract_nr,
ISNULL(c.tishcode,'') AS TS_Id,
c.tishactualenddate AS TS_end_date,
g.thisdaydate AS TSH_date
FROM resources a
INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
INNER join timesheets c ON c.tishasgtguid = b.asgtguid
INNER join users e ON e.userguid = a.rsrcuserguid
INNER join persons f ON e.userpersguid = f.persguid
INNER join timesheethistory g ON g.thistishguid = c.tishguid
WHERE a.rsrchqnumber = 80000147
and b.asgtassignmentid = 0000001234
and c.tishactualenddate > '20050619'
order by g.thisdaydate
PRINT 'HEAT 3213'Hi
1) DTS
2) BCP
<michaelnewport@.yahoo.com> wrote in message
news:1126768676.888961.311210@.g14g2000cwa.googlegroups.com...
> Greetings,
> I have what seems a simple problem...
> I want to save the output from the following queries in 1 file in
> 'SQL Query Analyser', but I can only save each 'grid' separately.
> I have about 30 queries in total. 'Messages' tells me the number of
> rows affected but I need the data.
> So can I save all the grids together at the same time in 1 file ?
> Thanks
> Mike
> PRINT 'HEAT 3510'
> SELECT f.persfirstname AS First_Name,
> f.perslastname AS Last_Name,
> a.rsrchqnumber AS Personal_nr,
> b.asgtassignmentid AS Contract_nr,
> ISNULL(c.tishcode,'') AS TS_Id,
> ISNULL(d.tpitpayrollcode,'6900') AS Pay_Code,
> d.tpitdaydate AS Payroll_Date,
> c.tishactualenddate AS TS_end_date
> FROM resources a
> INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
> INNER join timesheets c ON c.tishasgtguid = b.asgtguid
> INNER join users e ON e.userguid = a.rsrcuserguid
> INNER join persons f ON e.userpersguid = f.persguid
> LEFT OUTER join timesheetpayrollitems d ON d.tpittishguid =c.tishguid
> WHERE a.rsrchqnumber = 80000147
> and b.asgtassignmentid = 0000001234
> and c.tishactualenddate > '20050614'
> and (d.tpitdaydate > '20050614'
> or d.tpitdaydate IS null)
> order by d.tpitdaydate
> SELECT f.persfirstname AS First_Name,
> f.perslastname AS Last_Name,
> a.rsrchqnumber AS Personal_nr,
> b.asgtassignmentid AS Contract_nr,
> ISNULL(c.tishcode,'') AS TS_Id,
> c.tishactualenddate AS TS_end_date,
> g.thisdaydate AS TSH_date
> FROM resources a
> INNER join assignments b ON b.asgtrsrcguid = a.rsrcguid
> INNER join timesheets c ON c.tishasgtguid = b.asgtguid
> INNER join users e ON e.userguid = a.rsrcuserguid
> INNER join persons f ON e.userpersguid = f.persguid
> INNER join timesheethistory g ON g.thistishguid = c.tishguid
> WHERE a.rsrchqnumber = 80000147
> and b.asgtassignmentid = 0000001234
> and c.tishactualenddate > '20050619'
> order by g.thisdaydate
> PRINT 'HEAT 3213'
>|||Hi,
I have faced this problem just a month before.
u can do on thing
u can make 30 tables and tranfer the data to access database and carry
that access database anywhere .
in BCP file u have to maintain a lot.
in access u can create the table and keep on inserting in it.
hope that helps u
from
Doller

Wednesday, March 21, 2012

savepoint

hi all,
first of all thanks for giving me proper solution of my all
queries
now i want to know about savepoints in SQLServer 2000
where i will get detail information about this?
please let me know
thanks and regards
hrishikeshStart with Books Online in the SQL Server program group.Lots of info there, and no need to re-phrase
that here.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"hrishikesh musale" <musaleh@.mahindrabt.com> wrote in message
news:07e201c36df4$e5145a70$a401280a@.phx.gbl...
> hi all,
> first of all thanks for giving me proper solution of my all
> queries
> now i want to know about savepoints in SQLServer 2000
> where i will get detail information about this?
> please let me know
> thanks and regards
> hrishikesh
>
>

Saved SQL Queries

Can someone help me. In SQL Server 2005, when I save a query, and re-open it later, it always opens in the .master database. We do not use this database regularly, and I have to switch the database to the one that we use 95% of the time. Is there anyway to change the default database that opens, when I open these saved files for a given connection?


Thanks in advance for your help,


Wayne

You will have to include a USE statement within your database script to make the change. EVen the user defaultdb will not affect the connect to the master database.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||Thanks for the answer.

Tuesday, March 20, 2012

Save Query Designer Layout

I launch the Query Designer from the Microsoft SQL Server 2005 Management
Studio to design some queries. Can anyone tell me if there is a way to save
the graphical layout of the tables, joins, etc.? Am I missing something
really basic?
Rob (Rob@.discussions.microsoft.com) writes:
> I launch the Query Designer from the Microsoft SQL Server 2005
> Management Studio to design some queries. Can anyone tell me if there
> is a way to save the graphical layout of the tables, joins, etc.? Am I
> missing something really basic?
I don't think there any such option. If you feel this is important, you
can suggest it on http://connect.microsoft.com/sql
Personally, my enthusiasm for the Query Designer is low. There are
very many queries that it is not able to manage, and if you want to
evolve as an SQL programmer, using QD too much may hold you back.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
|||Thanks for the feedback Erland. I often use Query Designer just to get
started on the basics of a query. Is there another tool you recommend or is
your preference just to code the whole thing from scratch?
"Rob" wrote:

> I launch the Query Designer from the Microsoft SQL Server 2005 Management
> Studio to design some queries. Can anyone tell me if there is a way to save
> the graphical layout of the tables, joins, etc.? Am I missing something
> really basic?

Monday, March 12, 2012

save data to disc

Please help me?

I use sql express + C#, and when i execute my queries like "insert" into table, my data exist in dataset while i compile my project.
How i can save my data to my data source, and how i can see my data in my table in data source?

Please help me, how i can save my data from dataset into disc file mdf.

hi,

depending on your "use", you should check the InsertCommand of your object is accordingly set to your needs..

but, as you say you are using an Express edition of VS, chances are you actually save your "changes" to the datasource, but you "overwrite" the existing database physical files at each application start-up becouse of User Instances features and how you set the "Copy to Output Directory" property of the database's files... if you set it to "Copy Always", your changes will always be lost as the modified database's files will be overwritten at each application start-up by the old unmodified database physical files..

regards

|||Thank you Andrea, you are the best.|||It was very helpful for me!

thx

Friday, March 9, 2012

Save a join or two

We have several queries that involve quite a few joins (usually around 6-7).
The queries involve one main table linked via foreign keys to several other
tables, including both lookup and regular tables.
So far, we have been linking our foreign keys from the main table to Identity
columns in the external tables; however, we are now thinking of linking them
to the actual values. If, for example, we have a lookup table which only
contains an Identity, a value, and some other information of no interest
to anything but itself, and the value is defined as unique, then wouldn't
linking the foreign key straight to the unique value save us a join on that
table? Would it increase the size of the database, and if so, would that
even matter, considering that using the former approach we would be joining
the tables and retrieving the same amount of information anyway?
Any advice would be highly appreciated...Ido,
What you are debating here is whether to use a surrogate key in your look up
tables or not. You have identified that you will reduce the number of joins
you have by using one of your candidate keys as the primary key. This will
improve your database performance and may increase the amount of space used
marginally.
If you KNOW for sure that the values in your FK tables will NEVER change,
then I would remove the surrogate keys and use your candidate key. The
important thing is ensuring that any primary key does not change - this will
cause you big headaches.
Regards,
Mark.
"Ido Kalir" wrote:
> We have several queries that involve quite a few joins (usually around 6-7).
> The queries involve one main table linked via foreign keys to several other
> tables, including both lookup and regular tables.
> So far, we have been linking our foreign keys from the main table to Identity
> columns in the external tables; however, we are now thinking of linking them
> to the actual values. If, for example, we have a lookup table which only
> contains an Identity, a value, and some other information of no interest
> to anything but itself, and the value is defined as unique, then wouldn't
> linking the foreign key straight to the unique value save us a join on that
> table? Would it increase the size of the database, and if so, would that
> even matter, considering that using the former approach we would be joining
> the tables and retrieving the same amount of information anyway?
> Any advice would be highly appreciated...
>

Save a join or two

We have several queries that involve quite a few joins (usually around 6-7).
The queries involve one main table linked via foreign keys to several other
tables, including both lookup and regular tables.
So far, we have been linking our foreign keys from the main table to Identit
y
columns in the external tables; however, we are now thinking of linking them
to the actual values. If, for example, we have a lookup table which only
contains an Identity, a value, and some other information of no interest
to anything but itself, and the value is defined as unique, then wouldn't
linking the foreign key straight to the unique value save us a join on that
table? Would it increase the size of the database, and if so, would that
even matter, considering that using the former approach we would be joining
the tables and retrieving the same amount of information anyway?
Any advice would be highly appreciated...Ido,
What you are debating here is whether to use a surrogate key in your look up
tables or not. You have identified that you will reduce the number of joins
you have by using one of your candidate keys as the primary key. This will
improve your database performance and may increase the amount of space used
marginally.
If you KNOW for sure that the values in your FK tables will NEVER change,
then I would remove the surrogate keys and use your candidate key. The
important thing is ensuring that any primary key does not change - this will
cause you big headaches.
Regards,
Mark.
"Ido Kalir" wrote:

> We have several queries that involve quite a few joins (usually around 6-7
).
> The queries involve one main table linked via foreign keys to several othe
r
> tables, including both lookup and regular tables.
> So far, we have been linking our foreign keys from the main table to Ident
ity
> columns in the external tables; however, we are now thinking of linking th
em
> to the actual values. If, for example, we have a lookup table which only
> contains an Identity, a value, and some other information of no interest
> to anything but itself, and the value is defined as unique, then wouldn't
> linking the foreign key straight to the unique value save us a join on tha
t
> table? Would it increase the size of the database, and if so, would that
> even matter, considering that using the former approach we would be joinin
g
> the tables and retrieving the same amount of information anyway?
> Any advice would be highly appreciated...
>

Save a join or two

We have several queries that involve quite a few joins (usually around 6-7).
The queries involve one main table linked via foreign keys to several other
tables, including both lookup and regular tables.
So far, we have been linking our foreign keys from the main table to Identity
columns in the external tables; however, we are now thinking of linking them
to the actual values. If, for example, we have a lookup table which only
contains an Identity, a value, and some other information of no interest
to anything but itself, and the value is defined as unique, then wouldn't
linking the foreign key straight to the unique value save us a join on that
table? Would it increase the size of the database, and if so, would that
even matter, considering that using the former approach we would be joining
the tables and retrieving the same amount of information anyway?
Any advice would be highly appreciated...
Ido,
What you are debating here is whether to use a surrogate key in your look up
tables or not. You have identified that you will reduce the number of joins
you have by using one of your candidate keys as the primary key. This will
improve your database performance and may increase the amount of space used
marginally.
If you KNOW for sure that the values in your FK tables will NEVER change,
then I would remove the surrogate keys and use your candidate key. The
important thing is ensuring that any primary key does not change - this will
cause you big headaches.
Regards,
Mark.
"Ido Kalir" wrote:

> We have several queries that involve quite a few joins (usually around 6-7).
> The queries involve one main table linked via foreign keys to several other
> tables, including both lookup and regular tables.
> So far, we have been linking our foreign keys from the main table to Identity
> columns in the external tables; however, we are now thinking of linking them
> to the actual values. If, for example, we have a lookup table which only
> contains an Identity, a value, and some other information of no interest
> to anything but itself, and the value is defined as unique, then wouldn't
> linking the foreign key straight to the unique value save us a join on that
> table? Would it increase the size of the database, and if so, would that
> even matter, considering that using the former approach we would be joining
> the tables and retrieving the same amount of information anyway?
> Any advice would be highly appreciated...
>

sargable vs non-sargable queries

Hi,
is there some common instructions which WHERE clauses are sargable and which
of them are not?
thnks SinclairSARG is when you have:
colname <op> constant|variable|parameter
<op> includes: <, >, =, <=, >=, <>
Or something that will be converted to above, where
BETWEEN will be converted to:
col <= val AND col >= val
IN will be converted to
col = val1 OR col = val2
col LIKE 'A%' will be converted to
col >= 'A' AND col < 'B'
Things that are not SARG:
col * 25 = 12
SUBSTRING(col, 1, 4) = 'John'
col1 = col2
I.e., never do a calculation on the column side if you can avoid it.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Sinclair" <Sinclair@.discussions.microsoft.com> wrote in message
news:0D58C119-1984-4EAE-90BD-A4043567BC50@.microsoft.com...
> Hi,
> is there some common instructions which WHERE clauses are sargable and whi
ch
> of them are not?
> thnks Sinclair
>
>