Showing posts with label charset. Show all posts
Showing posts with label charset. Show all posts

Tuesday, March 20, 2012

ALTER table command

Hi,

I'm trying to run the ALTER TABLE command using a dynamic string for the
table, like so:

DECLARE @.TableName CHAR
SET @.TableName = 'Customers'
ALTER TABLE @.TableName
ADD ...blah

Is this possible? We know this works:

ALTER TABLE Customers ADD ...blah

It looks like I need a way to convert the CHAR value to a literal or perhaps
even a table ID?

Thanks in advance,
PaulYou would need to use dynamic query...

e.g.
exec('alter table '+@.tb+' add blah')

--
-oj
RAC v2.2 & QALite!
http://www.rac4sql.net

"Paul Sampson" <psampson@.uecomm.com.au> wrote in message
news:1061964209.790366@.proxy.uecomm.net.au...
> Hi,
> I'm trying to run the ALTER TABLE command using a dynamic string for the
> table, like so:
> DECLARE @.TableName CHAR
> SET @.TableName = 'Customers'
> ALTER TABLE @.TableName
> ADD ...blah
> Is this possible? We know this works:
> ALTER TABLE Customers ADD ...blah
> It looks like I need a way to convert the CHAR value to a literal or
perhaps
> even a table ID?
> Thanks in advance,
> Paul|||"Paul Sampson" <psampson@.uecomm.com.au> wrote in message news:<1061964209.790366@.proxy.uecomm.net.au>...
> Hi,
> I'm trying to run the ALTER TABLE command using a dynamic string for the
> table, like so:
> DECLARE @.TableName CHAR
> SET @.TableName = 'Customers'
> ALTER TABLE @.TableName
> ADD ...blah
> Is this possible? We know this works:
> ALTER TABLE Customers ADD ...blah
> It looks like I need a way to convert the CHAR value to a literal or perhaps
> even a table ID?
> Thanks in advance,
> Paul

You can use dynamic SQL:

declare @.tablename sysname
set @.tablename = 'Customers'
exec('alter table dbo.' + @.tablename + ' add ...')

See here for more information on dynamic SQL:

http://www.algonet.se/~sommar/dynamic_sql.html

By the way, if you declare a variable as CHAR without a length, it
will default to CHAR(1). For object names, sysname is a better choice.

Simon|||Thanks Simon - a common suggestion and one that I'll be sure to remember.

"Simon Hayes" <sql@.hayes.ch> wrote in message
news:60cd0137.0308270337.2bbb79e4@.posting.google.c om...
> "Paul Sampson" <psampson@.uecomm.com.au> wrote in message
news:<1061964209.790366@.proxy.uecomm.net.au>...
> > Hi,
> > I'm trying to run the ALTER TABLE command using a dynamic string for the
> > table, like so:
> > DECLARE @.TableName CHAR
> > SET @.TableName = 'Customers'
> > ALTER TABLE @.TableName
> > ADD ...blah
> > Is this possible? We know this works:
> > ALTER TABLE Customers ADD ...blah
> > It looks like I need a way to convert the CHAR value to a literal or
perhaps
> > even a table ID?
> > Thanks in advance,
> > Paul
> You can use dynamic SQL:
> declare @.tablename sysname
> set @.tablename = 'Customers'
> exec('alter table dbo.' + @.tablename + ' add ...')
> See here for more information on dynamic SQL:
> http://www.algonet.se/~sommar/dynamic_sql.html
> By the way, if you declare a variable as CHAR without a length, it
> will default to CHAR(1). For object names, sysname is a better choice.
> Simon

Thursday, February 9, 2012

Alignment etc...

This is a multi-part message in MIME format.
--=_NextPart_000_0028_01C6A504.9BB3C560
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
How can I align a field with the right margin of the report? With the = Matrix, the report width varies depending on the amount of data. I can = seem to find a way to specify that a control is anchored to the right = margin. Or maybe even centered in the page..
Help?
Jerry
--=_NextPart_000_0028_01C6A504.9BB3C560
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
How can I align a field with the right = margin of the report? With the Matrix, the report width varies depending on = the amount of data. I can seem to find a way to specify that a control = is anchored to the right margin. Or maybe even centered in the page..

Help?

Jerry
--=_NextPart_000_0028_01C6A504.9BB3C560--Hi Jerry,
Thank you for your posting!
Based on my test, you could just put the textbox next to the right border
of your report. The textbox will align with the right border of the report.
Please try and let me know the result.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Thanks, Wei... But that doesn't work. Since the report is wider when it's
run than it is in the designer. And there's no way to determine, at design
time, how wide the report will, as the matrix expands dynamically based on
the criteria entered by the user at run time.
So... Is there any way to dynamically position any of the controls at run
time?
Thanks.
Jerry
"Wei Lu [MSFT]" <weilu@.online.microsoft.com> wrote in message
news:TWFXnMYpGHA.4612@.TK2MSFTNGXA01.phx.gbl...
> Hi Jerry,
> Thank you for your posting!
> Based on my test, you could just put the textbox next to the right border
> of your report. The textbox will align with the right border of the
> report.
> Please try and let me know the result.
> Sincerely,
> Wei Lu
> Microsoft Online Community Support
> ==================================================> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>|||Hi Jerry,
Thank you for the update.
You could not control the position of the control dynamically in the
report.
If the text box left border is next to the right border of the matrix, the
textbox will be position on the right of the matrix.
Hope this will be helpful.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Hello Jerry,
How are you doing on this issue? Does Wei's suggestion in the last reply
helps you some? If you still have any problems or need any further
assistance, please feel free to post here.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.|||I'm not sure I understand his suggestion at all... I have a textbox just
below and aligned with the right border of the matrix...
At run time, the matrix expands to accomodate maybe 3 to 7 columns,
depending on data. But the textbox stays at the position it was at in the
designer.
I want the text box's right edge position to stay aligned with the right
edge of the matrix as it expands.
Thanks.
Jerry
"Steven Cheng[MSFT]" <stcheng@.online.microsoft.com> wrote in message
news:$TtwwejqGHA.2024@.TK2MSFTNGXA01.phx.gbl...
> Hello Jerry,
> How are you doing on this issue? Does Wei's suggestion in the last reply
> helps you some? If you still have any problems or need any further
> assistance, please feel free to post here.
> Sincerely,
> Steven Cheng
> Microsoft MSDN Online Support Lead
>
> =================================================>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>