Showing posts with label statements. Show all posts
Showing posts with label statements. Show all posts

Friday, March 30, 2012

How to rename a table ?

Hi all.

I'm porting an application from eVB-ADOCE to VB.Net-SQL CE

In the old application there are some SQL statements like this:

"ALTER TABLE OldTable TO NewTable"

Is there an equivalent instruction or a simple way to rename a table?

I was not able to find anything simple to do the same.

I really need NOT to do something like

SELECT * INTO NewTable FROM OldTable

because the resulting table could go outside memory and/or spend too much time in elaboration.

Please let me know what I can do.

Many thanks !

As far as I know, there is no such option from SQL. But you can rename a table (and a table column) using OLE DB:

QA: How do I rename a SQL CE table?

|||This is very interesting, and I read your article, but I'm so ignorant in C++ that I've not been able to translate your code in VB. |||

Don't worry - I'm working on an article that will allow you to do this from .NET CF on a device. I will post this article either today or tomorrow.

|||

Jo?o Paulo Figueira wrote:

Don't worry - I'm working on an article that will allow you to do this from .NET CF on a device. I will post this article either today or tomorrow.

That will be wonderful !

|||

As promised, here is the article:

Renaming a SQL CE Table From a .NET CF Application

|||

Joao Paulo,

I don't know how to say "thank you" for your kindness. I'm going to use your work just now.

If you come to Milano (Italy), please let me know ! I shall organize a good dinner for you

Thank you very much again !

Wednesday, March 21, 2012

How to refer from a stored procedure to a table in another dat

"Bob Barrows [MVP]" wrote:

> Two options that I can think of:
> 1.A series of IF statements, which I'm pretty sure would be the solution o
f
> choice, given that you don't have more than 10 or so databases ...
> 2. Another option is to create a view that unions the tables including a
> column for source database name (I think this is how partitioning is
> implemented )
1. Could you describe in more details how first way will help me to pass a
database name as a parameter. Database name must not be hardcoded in any for
m
even not in several IFs.
2. I can not do anything beforehand. The procedure is guaranteed to be given
a database of certain structure. That is all.
Thanks for replyAlexander Korol wrote:
> "Bob Barrows [MVP]" wrote:
>
> 1. Could you describe in more details how first way will help me to
> pass a database name as a parameter. Database name must not be
> hardcoded in any form
Why not? You're not creating db's dynamically are you?

> even not in several IFs.
IF @.dbname = thisdb
select ... from thisdb..table
IF @.dbname = thatdb
select ... from thatdb..table
...
But if what you say is true, this method is ruled out.

> 2. I can not do anything beforehand. The procedure is guaranteed to
> be given a database of certain structure. That is all.
>
Then you are forced to use dynamic sql ... ugh!!
Somebody needs to rethink this architecture ...
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Friday, March 9, 2012

How to read in multiple SELECT statements of different return types in T-SQL

HI,
I understand how to use NextResultset() in ADO.NET to return multiple
readers from a stored proc. What if a SELECT returns a scalar and
another returns rows.
Thank you!> What if a SELECT returns a scalar and
> another returns rows.
Let me rephrase above:
"What is a SELECT returns a scalar and another returns a table"
Actually all SELECT statements returns tables (with some obscure exceptions like COMPUTE). So, a
scalar is just a table that happens to have only one column and one row. I.e., you treat is as a
table. The ExecuteScalar method is just something that ADO.NET designers cooked up to make it easier
for us to get the value from a select statement that returns a table with one column and one row.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
<webdevaccount@.gmail.com> wrote in message
news:1182811103.414233.319970@.m36g2000hse.googlegroups.com...
> HI,
> I understand how to use NextResultset() in ADO.NET to return multiple
> readers from a stored proc. What if a SELECT returns a scalar and
> another returns rows.
> Thank you!
>