Showing posts with label selecting. Show all posts
Showing posts with label selecting. Show all posts

Sunday, March 25, 2012

create table as

I want to create table from
selecting records from another table In sql server 7.0
e.g
create table tablename
as
select * from another table/view.
How is it possible ??

Thanx in Advance.Hi To create a new table use

SELECT *
INTO fred
FROM bill
IT will fail if fred already exists

To empty and reuse then use

Truncate fred
INSERT INTO fred
SELECT *
FROM bill

Did I get the question right ?

Gerry|||I want to create table from
selecting records from another table In sql server 7.0
e.g
create table tablename
as
select * from another table/view.
How is it possible ??

Thanx in Advance.

WOW, you sound like a DB2 person...

Just don't use SELECT * if it's for Production.....|||Quite right about the "*" of course... I'm just a lazy typer :)

As for the DB2 guess:- not even close !|||Gerry, not you...dbtechzala

The syntax is close to a DB2 syntax....

Be careful of the TRUNCATE though...it'll mark every page as being deleted...

no where clause there....

create table

Hi
How to create a table by selecting data from different tables.
Can we create table with actual data while selecting data from different
tables. If yes what is the syntex.
=============
Syntex for createing a view is
create view as
SELECT table1.code1, table1.field1, table2.field2
FROM
table1 INNER JOIN table2 ON table1.code1 = table2.code1
=============
Thanks
Jpr
On Nov 28, 1:27 am, "Henrik Davidsen" <n...@.none.dk> wrote:
> This is not tested, but the construct SELECT INTO should do it:
> SELECT table1.code1, table1.field1, table2.field2 INTO newTable
> FROM
> table1 INNER JOIN table2 ON table1.code1 = table2.code1
> /Sjang
Note that the target table wont have the indices that source table has

create table

Hi
How to create a table by selecting data from different tables.
Can we create table with actual data while selecting data from different
tables. If yes what is the syntex.
============= Syntex for createing a view is
create view as
SELECT table1.code1, table1.field1, table2.field2
FROM
table1 INNER JOIN table2 ON table1.code1 = table2.code1
=============
Thanks
Jpr> How to create a table by selecting data from different tables.
> Can we create table with actual data while selecting data from different
> tables. If yes what is the syntex.
> =============> Syntex for createing a view is
> create view as
> SELECT table1.code1, table1.field1, table2.field2
> FROM
> table1 INNER JOIN table2 ON table1.code1 = table2.code1
> =============
This is not tested, but the construct SELECT INTO should do it:
SELECT table1.code1, table1.field1, table2.field2 INTO newTable
FROM
table1 INNER JOIN table2 ON table1.code1 = table2.code1
/Sjang|||On Nov 28, 1:27 am, "Henrik Davidsen" <n...@.none.dk> wrote:
> > How to create a table by selecting data from different tables.
> > Can we create table with actual data while selecting data from different
> > tables. If yes what is the syntex.
> > =============> > Syntex for createing a view is
> > create view as
> > SELECT table1.code1, table1.field1, table2.field2
> > FROM
> > table1 INNER JOIN table2 ON table1.code1 = table2.code1
> > =============> This is not tested, but the construct SELECT INTO should do it:
> SELECT table1.code1, table1.field1, table2.field2 INTO newTable
> FROM
> table1 INNER JOIN table2 ON table1.code1 = table2.code1
> /Sjang
Note that the target table wont have the indices that source table hassql

create table

Hi
How to create a table by selecting data from different tables.
Can we create table with actual data while selecting data from different
tables. If yes what is the syntex.
=============
Syntex for createing a view is
create view as
SELECT table1.code1, table1.field1, table2.field2
FROM
table1 INNER JOIN table2 ON table1.code1 = table2.code1
=============
Thanks
Jpr> How to create a table by selecting data from different tables.
> Can we create table with actual data while selecting data from different
> tables. If yes what is the syntex.
> =============
> Syntex for createing a view is
> create view as
> SELECT table1.code1, table1.field1, table2.field2
> FROM
> table1 INNER JOIN table2 ON table1.code1 = table2.code1
> =============
This is not tested, but the construct SELECT INTO should do it:
SELECT table1.code1, table1.field1, table2.field2 INTO newTable
FROM
table1 INNER JOIN table2 ON table1.code1 = table2.code1
/Sjang|||On Nov 28, 1:27 am, "Henrik Davidsen" <n...@.none.dk> wrote:
> This is not tested, but the construct SELECT INTO should do it:
> SELECT table1.code1, table1.field1, table2.field2 INTO newTable
> FROM
> table1 INNER JOIN table2 ON table1.code1 = table2.code1
> /Sjang
Note that the target table wont have the indices that source table has

Monday, March 19, 2012

Create query from table SS2K vs. SS2005

Hello,
When using SS2K, you can create a query by right-mouse click on the table
and then selecting "query" in the Enterprise Manager. How do you do this in
SS2005 when using the Management Studio? When I right-mouse click on the
table, the only option I have is to select "Open", which runs the whole
dataset.
Thanks in advance,
StevenHi Steven,
If you're just looking to add a filter before running the query, then
when you right click on the table, you can select
Script Table As > SELECT to > New Query Editor Window | Clipboard |
File
Hopefully that's close to what you had in mind.|||If it is the query builder you are after, you can reach it from the view fol
der. Right-click, new
view, construct the query and you then don't have to save it as a view. Pers
onally, I don't
appreciate query builders, though. I find them too limiting and they don't a
llow me to expand on my
SQL knowledge.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Steven K0" <stroy@.api.com> wrote in message news:eDpZyG2LGHA.2316@.TK2MSFTNGP11.phx.gbl...[v
bcol=seagreen]
> Hello,
> When using SS2K, you can create a query by right-mouse click on the table
and then selecting
> "query" in the Enterprise Manager. How do you do this in SS2005 when usin
g the Management Studio?
> When I right-mouse click on the table, the only option I have is to select
"Open", which runs the
> whole dataset.
> --
> Thanks in advance,
> Steven
>[/vbcol]|||
> Personally, I don't appreciate query builders, though.
> I find them too limiting and they don't allow me to
> expand on my SQL knowledge.
Dear Tibor,
I beg to differ with you about limited functionality of query builders.
Recently I've found one that differs from the rest. Active Query Builder
can build queries with unions and sub-queries. I can't find nothing in
it that could be called 'limitation', this is just a useful addition to
the text editor. And it keeps my queries untouched even it has no
appropriate visual control for some of their clauses.
Sincerely
Sergey Smagin
*** Sent via Developersdex http://www.codecomments.com ***|||> I beg to differ with you about limited functionality of query builders.
Sorry, I should have said that I find the Query builder that comes with Ente
rprise Manager and
Visual Studio limiting. These are the only one I've tried (apart from the on
e found in Excel a long
time ago). I can imagine that there are other QBs out there that are more po
werful.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Ron Simnard" <nospam@.devdex.com> wrote in message news:uII9tUMMGHA.1532@.TK2MSFTNGP12.phx.gb
l...
>
> Dear Tibor,
> I beg to differ with you about limited functionality of query builders.
> Recently I've found one that differs from the rest. Active Query Builder
> can build queries with unions and sub-queries. I can't find nothing in
> it that could be called 'limitation', this is just a useful addition to
> the text editor. And it keeps my queries untouched even it has no
> appropriate visual control for some of their clauses.
> Sincerely
> Sergey Smagin
> *** Sent via Developersdex http://www.codecomments.com ***

Create query from table SS2K vs. SS2005

Hello,
When using SS2K, you can create a query by right-mouse click on the table
and then selecting "query" in the Enterprise Manager. How do you do this in
SS2005 when using the Management Studio? When I right-mouse click on the
table, the only option I have is to select "Open", which runs the whole
dataset.
Thanks in advance,
Steven
Hi Steven,
If you're just looking to add a filter before running the query, then
when you right click on the table, you can select
Script Table As > SELECT to > New Query Editor Window | Clipboard |
File
Hopefully that's close to what you had in mind.
|||If it is the query builder you are after, you can reach it from the view folder. Right-click, new
view, construct the query and you then don't have to save it as a view. Personally, I don't
appreciate query builders, though. I find them too limiting and they don't allow me to expand on my
SQL knowledge.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Steven K0" <stroy@.api.com> wrote in message news:eDpZyG2LGHA.2316@.TK2MSFTNGP11.phx.gbl...
> Hello,
> When using SS2K, you can create a query by right-mouse click on the table and then selecting
> "query" in the Enterprise Manager. How do you do this in SS2005 when using the Management Studio?
> When I right-mouse click on the table, the only option I have is to select "Open", which runs the
> whole dataset.
> --
> Thanks in advance,
> Steven
>
|||
> Personally, I don't appreciate query builders, though.
> I find them too limiting and they don't allow me to
> expand on my SQL knowledge.
Dear Tibor,
I beg to differ with you about limited functionality of query builders.
Recently I've found one that differs from the rest. Active Query Builder
can build queries with unions and sub-queries. I can't find nothing in
it that could be called 'limitation', this is just a useful addition to
the text editor. And it keeps my queries untouched even it has no
appropriate visual control for some of their clauses.
Sincerely
Sergey Smagin
*** Sent via Developersdex http://www.codecomments.com ***
|||> I beg to differ with you about limited functionality of query builders.
Sorry, I should have said that I find the Query builder that comes with Enterprise Manager and
Visual Studio limiting. These are the only one I've tried (apart from the one found in Excel a long
time ago). I can imagine that there are other QBs out there that are more powerful.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Ron Simnard" <nospam@.devdex.com> wrote in message news:uII9tUMMGHA.1532@.TK2MSFTNGP12.phx.gbl...
>
> Dear Tibor,
> I beg to differ with you about limited functionality of query builders.
> Recently I've found one that differs from the rest. Active Query Builder
> can build queries with unions and sub-queries. I can't find nothing in
> it that could be called 'limitation', this is just a useful addition to
> the text editor. And it keeps my queries untouched even it has no
> appropriate visual control for some of their clauses.
> Sincerely
> Sergey Smagin
> *** Sent via Developersdex http://www.codecomments.com ***

Create query from table SS2K vs. SS2005

Hello,
When using SS2K, you can create a query by right-mouse click on the table
and then selecting "query" in the Enterprise Manager. How do you do this in
SS2005 when using the Management Studio? When I right-mouse click on the
table, the only option I have is to select "Open", which runs the whole
dataset.
--
Thanks in advance,
StevenHi Steven,
If you're just looking to add a filter before running the query, then
when you right click on the table, you can select
Script Table As > SELECT to > New Query Editor Window | Clipboard |
File
Hopefully that's close to what you had in mind.|||If it is the query builder you are after, you can reach it from the view folder. Right-click, new
view, construct the query and you then don't have to save it as a view. Personally, I don't
appreciate query builders, though. I find them too limiting and they don't allow me to expand on my
SQL knowledge.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Steven K0" <stroy@.api.com> wrote in message news:eDpZyG2LGHA.2316@.TK2MSFTNGP11.phx.gbl...
> Hello,
> When using SS2K, you can create a query by right-mouse click on the table and then selecting
> "query" in the Enterprise Manager. How do you do this in SS2005 when using the Management Studio?
> When I right-mouse click on the table, the only option I have is to select "Open", which runs the
> whole dataset.
> --
> Thanks in advance,
> Steven
>