I have a situation which seems like it should have a fairly simple
answer... but I'm not sure how to do it.
I want to create a view that joins several remotely distributed tables.
Something like:
CREATE VIEW AllData
AS
SELECT * FROM Server1.SomeDB.dbo.DataTable
UNION ALL
SELECT * FROM Server2.SomeDB.dbo.DataTable
...
SELECT * FROM ServerN.SomeDB.dbo.DataTable
The problem is that we anticipate some downtime or discontinuity with
our server links. Will the view fail if just ONE server can't be
reached? I think it will... please correct me if I'm wrong.
So, to solve this we have another table which stores the server name
and a status field. The question is how do I take this list of
available servers and turn it into a valid view? Is this going to
require some form of dynamic SQL? I'm picturing creating a trigger so
that any time the status DB changes the view gets recreated.status table could be out of sync and you will still get error. Long story
short, there isn't anything builtin right now to allow you precheck for
linked server status other than sending a query to it.
-oj
<bryanp10@.hotmail.com> wrote in message
news:1113511868.193053.138020@.l41g2000cwc.googlegroups.com...
>I have a situation which seems like it should have a fairly simple
> answer... but I'm not sure how to do it.
> I want to create a view that joins several remotely distributed tables.
> Something like:
> CREATE VIEW AllData
> AS
> SELECT * FROM Server1.SomeDB.dbo.DataTable
> UNION ALL
> SELECT * FROM Server2.SomeDB.dbo.DataTable
> ...
> SELECT * FROM ServerN.SomeDB.dbo.DataTable
>
> The problem is that we anticipate some downtime or discontinuity with
> our server links. Will the view fail if just ONE server can't be
> reached? I think it will... please correct me if I'm wrong.
> So, to solve this we have another table which stores the server name
> and a status field. The question is how do I take this list of
> available servers and turn it into a valid view? Is this going to
> require some form of dynamic SQL? I'm picturing creating a trigger so
> that any time the status DB changes the view gets recreated.
>|||OK... not quite what I was asking, but thanks. :)
Basically, I'm useless in T-SQL and what I really need to know is how
to transform a table of server names into:
select * from server1
UNION ALL
select * from server2
...
etc.
Really this is just a basic T-SQL question. In ANY other programming
language I've ever seen, this would be simplicity itself. But for some
reason T-SQL just baffles me.
The other question was whether this absolutely requires dynamic SQL or
not. At this point I'm thinking I might just build the create view
procedure in my app where I have a real language to do it.
Showing posts with label situation. Show all posts
Showing posts with label situation. Show all posts
Monday, March 19, 2012
Wednesday, March 7, 2012
Creating a Dimension Table from a 3-key table
Hi All,
I have a situation with a table that was created for a transactional
system with a 3 columns key. The table is similar to the following:
country state city description
1 12 21 City A from country 1 and state 12
1 13 21 City A from country 1 and state 13
2 14 22 City B from country 2 and state 14
2 15 22 City B from country 2 and state 15
Now I'm trying to create a dts package that would allow me to build a
city dimension table with unique codes (keys) for each city. What kind of
transformation should I use to translate the old codes (based on the
country-state-city key) into the new ones and preserving the data
integrity?
Thanks,
Ignaciodoesn't that defeat the purpose of building a cube?
What's it going to be for?
How are you going to go after the data?|||This cube is going to show sales history since 2002. The table where data is being pulled could contain data as the following:
cust_id year country state city amount_cash amount_credit
525 2002 1 12 21 8500 3200
714 2002 1 13 21 3250 775
Let's say I create a fact table with fk and measures only. If I would like to know city totals, it looks like cities sharing the same id will be aggregated, when in fact they shouldn't. And in the other hand, cities that are geographically shared by different states will add up correctly. Maybe I need to further analyze this, but what first puzzled me was the city table with no unique id.
Thanks for your thoughts!
Ignacio
I have a situation with a table that was created for a transactional
system with a 3 columns key. The table is similar to the following:
country state city description
1 12 21 City A from country 1 and state 12
1 13 21 City A from country 1 and state 13
2 14 22 City B from country 2 and state 14
2 15 22 City B from country 2 and state 15
Now I'm trying to create a dts package that would allow me to build a
city dimension table with unique codes (keys) for each city. What kind of
transformation should I use to translate the old codes (based on the
country-state-city key) into the new ones and preserving the data
integrity?
Thanks,
Ignaciodoesn't that defeat the purpose of building a cube?
What's it going to be for?
How are you going to go after the data?|||This cube is going to show sales history since 2002. The table where data is being pulled could contain data as the following:
cust_id year country state city amount_cash amount_credit
525 2002 1 12 21 8500 3200
714 2002 1 13 21 3250 775
Let's say I create a fact table with fk and measures only. If I would like to know city totals, it looks like cities sharing the same id will be aggregated, when in fact they shouldn't. And in the other hand, cities that are geographically shared by different states will add up correctly. Maybe I need to further analyze this, but what first puzzled me was the city table with no unique id.
Thanks for your thoughts!
Ignacio
Creating a diagram automatically through Enterprise Manager
Hi all,
I'm wondering, is there any way to have SQL Server automatically generate
a diagram via Enterprise Manager?
The situation is, I have created a database by executing a big as script
of SQL. The script created the tables and views and added the primary key
constraints etc. However there isnt a diagram available to help me understan
d
the schema a bit easier.
Is there some way to have Enterprise Manager interpret the schema and the
constraints and reverse engineer a pretty diagram for me?
Thanks to anyone who can advise
Kindest Regards
tce
Kindest Regards
tceIsn't it as easy as creating a new Diagram and adding all the tables?
Not to belittle the task, but the wizard is pretty good? It isn't the
automated approach but works none the less.
Clint Hill
H3O Software
http://www.h3osoftware.com
thechaosengine wrote:
> Hi all,
> I'm wondering, is there any way to have SQL Server automatically
> generate a diagram via Enterprise Manager?
> The situation is, I have created a database by executing a big as script
> of SQL. The script created the tables and views and added the primary
> key constraints etc. However there isnt a diagram available to help me
> understand the schema a bit easier.
> Is there some way to have Enterprise Manager interpret the schema and
> the constraints and reverse engineer a pretty diagram for me?
> Thanks to anyone who can advise
> Kindest Regards
> tce
> Kindest Regards
> tce
>|||Hi Clint
Thanks for your reply. You are quite right, the wizard does generate the
diagram! I must confess to being a bit stupid here. I normally use Access
connected to SQL Server to develop the database and access doesn't have quit
e
the same functionality in this regard. I actually assumed that the diagramin
g
features were identical. They certainly seem very similar.
Thanks for your help!
Kindest Regards
tce
[vbcol=seagreen]
> Isn't it as easy as creating a new Diagram and adding all the tables?
> Not to belittle the task, but the wizard is pretty good? It isn't the
> automated approach but works none the less.
> Clint Hill
> H3O Software
> http://www.h3osoftware.com
> thechaosengine wrote:
>
I'm wondering, is there any way to have SQL Server automatically generate
a diagram via Enterprise Manager?
The situation is, I have created a database by executing a big as script
of SQL. The script created the tables and views and added the primary key
constraints etc. However there isnt a diagram available to help me understan
d
the schema a bit easier.
Is there some way to have Enterprise Manager interpret the schema and the
constraints and reverse engineer a pretty diagram for me?
Thanks to anyone who can advise
Kindest Regards
tce
Kindest Regards
tceIsn't it as easy as creating a new Diagram and adding all the tables?
Not to belittle the task, but the wizard is pretty good? It isn't the
automated approach but works none the less.
Clint Hill
H3O Software
http://www.h3osoftware.com
thechaosengine wrote:
> Hi all,
> I'm wondering, is there any way to have SQL Server automatically
> generate a diagram via Enterprise Manager?
> The situation is, I have created a database by executing a big as script
> of SQL. The script created the tables and views and added the primary
> key constraints etc. However there isnt a diagram available to help me
> understand the schema a bit easier.
> Is there some way to have Enterprise Manager interpret the schema and
> the constraints and reverse engineer a pretty diagram for me?
> Thanks to anyone who can advise
> Kindest Regards
> tce
> Kindest Regards
> tce
>|||Hi Clint
Thanks for your reply. You are quite right, the wizard does generate the
diagram! I must confess to being a bit stupid here. I normally use Access
connected to SQL Server to develop the database and access doesn't have quit
e
the same functionality in this regard. I actually assumed that the diagramin
g
features were identical. They certainly seem very similar.
Thanks for your help!
Kindest Regards
tce
[vbcol=seagreen]
> Isn't it as easy as creating a new Diagram and adding all the tables?
> Not to belittle the task, but the wizard is pretty good? It isn't the
> automated approach but works none the less.
> Clint Hill
> H3O Software
> http://www.h3osoftware.com
> thechaosengine wrote:
>
Labels:
automatically,
creating,
database,
diagram,
enterprise,
generatea,
manager,
managerthe,
microsoft,
mysql,
oracle,
server,
situation,
sql,
via
Creating a diagram automatically through Enterprise Manager
Hi all,
I'm wondering, is there any way to have SQL Server automatically generate
a diagram via Enterprise Manager?
The situation is, I have created a database by executing a big as script
of SQL. The script created the tables and views and added the primary key
constraints etc. However there isnt a diagram available to help me understand
the schema a bit easier.
Is there some way to have Enterprise Manager interpret the schema and the
constraints and reverse engineer a pretty diagram for me?
Thanks to anyone who can advise
Kindest Regards
tce
Kindest Regards
tce
Isn't it as easy as creating a new Diagram and adding all the tables?
Not to belittle the task, but the wizard is pretty good? It isn't the
automated approach but works none the less.
Clint Hill
H3O Software
http://www.h3osoftware.com
thechaosengine wrote:
> Hi all,
> I'm wondering, is there any way to have SQL Server automatically
> generate a diagram via Enterprise Manager?
> The situation is, I have created a database by executing a big as script
> of SQL. The script created the tables and views and added the primary
> key constraints etc. However there isnt a diagram available to help me
> understand the schema a bit easier.
> Is there some way to have Enterprise Manager interpret the schema and
> the constraints and reverse engineer a pretty diagram for me?
> Thanks to anyone who can advise
> Kindest Regards
> tce
> Kindest Regards
> tce
>
|||Hi Clint
Thanks for your reply. You are quite right, the wizard does generate the
diagram! I must confess to being a bit stupid here. I normally use Access
connected to SQL Server to develop the database and access doesn't have quite
the same functionality in this regard. I actually assumed that the diagraming
features were identical. They certainly seem very similar.
Thanks for your help!
Kindest Regards
tce
[vbcol=seagreen]
> Isn't it as easy as creating a new Diagram and adding all the tables?
> Not to belittle the task, but the wizard is pretty good? It isn't the
> automated approach but works none the less.
> Clint Hill
> H3O Software
> http://www.h3osoftware.com
> thechaosengine wrote:
I'm wondering, is there any way to have SQL Server automatically generate
a diagram via Enterprise Manager?
The situation is, I have created a database by executing a big as script
of SQL. The script created the tables and views and added the primary key
constraints etc. However there isnt a diagram available to help me understand
the schema a bit easier.
Is there some way to have Enterprise Manager interpret the schema and the
constraints and reverse engineer a pretty diagram for me?
Thanks to anyone who can advise
Kindest Regards
tce
Kindest Regards
tce
Isn't it as easy as creating a new Diagram and adding all the tables?
Not to belittle the task, but the wizard is pretty good? It isn't the
automated approach but works none the less.
Clint Hill
H3O Software
http://www.h3osoftware.com
thechaosengine wrote:
> Hi all,
> I'm wondering, is there any way to have SQL Server automatically
> generate a diagram via Enterprise Manager?
> The situation is, I have created a database by executing a big as script
> of SQL. The script created the tables and views and added the primary
> key constraints etc. However there isnt a diagram available to help me
> understand the schema a bit easier.
> Is there some way to have Enterprise Manager interpret the schema and
> the constraints and reverse engineer a pretty diagram for me?
> Thanks to anyone who can advise
> Kindest Regards
> tce
> Kindest Regards
> tce
>
|||Hi Clint
Thanks for your reply. You are quite right, the wizard does generate the
diagram! I must confess to being a bit stupid here. I normally use Access
connected to SQL Server to develop the database and access doesn't have quite
the same functionality in this regard. I actually assumed that the diagraming
features were identical. They certainly seem very similar.
Thanks for your help!
Kindest Regards
tce
[vbcol=seagreen]
> Isn't it as easy as creating a new Diagram and adding all the tables?
> Not to belittle the task, but the wizard is pretty good? It isn't the
> automated approach but works none the less.
> Clint Hill
> H3O Software
> http://www.h3osoftware.com
> thechaosengine wrote:
Creating a diagram automatically through Enterprise Manager
Hi all,
I'm wondering, is there any way to have SQL Server automatically generate
a diagram via Enterprise Manager?
The situation is, I have created a database by executing a big as script
of SQL. The script created the tables and views and added the primary key
constraints etc. However there isnt a diagram available to help me understand
the schema a bit easier.
Is there some way to have Enterprise Manager interpret the schema and the
constraints and reverse engineer a pretty diagram for me?
Thanks to anyone who can advise
Kindest Regards
tce
Kindest Regards
tceIsn't it as easy as creating a new Diagram and adding all the tables?
Not to belittle the task, but the wizard is pretty good? It isn't the
automated approach but works none the less.
Clint Hill
H3O Software
http://www.h3osoftware.com
thechaosengine wrote:
> Hi all,
> I'm wondering, is there any way to have SQL Server automatically
> generate a diagram via Enterprise Manager?
> The situation is, I have created a database by executing a big as script
> of SQL. The script created the tables and views and added the primary
> key constraints etc. However there isnt a diagram available to help me
> understand the schema a bit easier.
> Is there some way to have Enterprise Manager interpret the schema and
> the constraints and reverse engineer a pretty diagram for me?
> Thanks to anyone who can advise
> Kindest Regards
> tce
> Kindest Regards
> tce
>
I'm wondering, is there any way to have SQL Server automatically generate
a diagram via Enterprise Manager?
The situation is, I have created a database by executing a big as script
of SQL. The script created the tables and views and added the primary key
constraints etc. However there isnt a diagram available to help me understand
the schema a bit easier.
Is there some way to have Enterprise Manager interpret the schema and the
constraints and reverse engineer a pretty diagram for me?
Thanks to anyone who can advise
Kindest Regards
tce
Kindest Regards
tceIsn't it as easy as creating a new Diagram and adding all the tables?
Not to belittle the task, but the wizard is pretty good? It isn't the
automated approach but works none the less.
Clint Hill
H3O Software
http://www.h3osoftware.com
thechaosengine wrote:
> Hi all,
> I'm wondering, is there any way to have SQL Server automatically
> generate a diagram via Enterprise Manager?
> The situation is, I have created a database by executing a big as script
> of SQL. The script created the tables and views and added the primary
> key constraints etc. However there isnt a diagram available to help me
> understand the schema a bit easier.
> Is there some way to have Enterprise Manager interpret the schema and
> the constraints and reverse engineer a pretty diagram for me?
> Thanks to anyone who can advise
> Kindest Regards
> tce
> Kindest Regards
> tce
>
Friday, February 17, 2012
Create view with field combination
Hi there, my situation is
I have a table x with 3 filed
a nvarchar(100), b smalldatetime, c text(16)
. I want to create a view like this:
select a + ' ' + b + ' ' + c as all_field from x where all_field like %my_str%
So, I always get a message error said wrong datatype, how can i do, please help me.A view is just a select statement basically, meaning if you can't get something to compile in Query Analyzer it's not going to compile as a view. The syntax for a select statement similar to yours (there's nothing like yours that will actually compile) is:
SELECT column1 + '' + column2 + '' + column3 AS all_fields
FROM x
WHERE column1 + '' + column2 + '' + column3 LIKE '%my_str%'
Notice the single quotes and the fact that the column alias was not used in the where clause.
It's kind of like the following SELECT statements:
select name as huh from sysobjects where huh like '%a%'
select name from sysobjects where name like '%a%'
Only one of those actually pretends to work. :)|||The alias (all_field) is applied to the result set at the end of execution, so you can't reference in your statement.
In addition to Derrick;s method, this would normally work:
select all_field
from (select a + ' ' + b + ' ' + c as all_field from x) CombinedColumns
where all_field like %my_str%
...but I think you are going to run into problems with the TEXT column type. Notice that it's size is only 16 bytes. That is because the TEXT column is actually just a pointer to the location where the actual column value is stored. So your statement is trying to concatenate a pointer address to the end of your nvarchar and smalldatetime fields. I'm sure that's not what you want.
You will need to concatenate the actual value of column C, not it's address.
I have a table x with 3 filed
a nvarchar(100), b smalldatetime, c text(16)
. I want to create a view like this:
select a + ' ' + b + ' ' + c as all_field from x where all_field like %my_str%
So, I always get a message error said wrong datatype, how can i do, please help me.A view is just a select statement basically, meaning if you can't get something to compile in Query Analyzer it's not going to compile as a view. The syntax for a select statement similar to yours (there's nothing like yours that will actually compile) is:
SELECT column1 + '' + column2 + '' + column3 AS all_fields
FROM x
WHERE column1 + '' + column2 + '' + column3 LIKE '%my_str%'
Notice the single quotes and the fact that the column alias was not used in the where clause.
It's kind of like the following SELECT statements:
select name as huh from sysobjects where huh like '%a%'
select name from sysobjects where name like '%a%'
Only one of those actually pretends to work. :)|||The alias (all_field) is applied to the result set at the end of execution, so you can't reference in your statement.
In addition to Derrick;s method, this would normally work:
select all_field
from (select a + ' ' + b + ' ' + c as all_field from x) CombinedColumns
where all_field like %my_str%
...but I think you are going to run into problems with the TEXT column type. Notice that it's size is only 16 bytes. That is because the TEXT column is actually just a pointer to the location where the actual column value is stored. So your statement is trying to concatenate a pointer address to the end of your nvarchar and smalldatetime fields. I'm sure that's not what you want.
You will need to concatenate the actual value of column C, not it's address.
Subscribe to:
Posts (Atom)