Showing posts with label syntax. Show all posts
Showing posts with label syntax. Show all posts

Thursday, March 29, 2012

Does SQL Server support "after" on alter table ?

Hello,
I'm trying to do this:
alter table maquinas add marca varchar(50) after modelo
and I get the following error:
Incorrect syntax near 'after'.
What is going on?
hans
No, you cannot tell SQL Server where to add a column. It gets apended to
the "end". Why is column order important? Yes, Management Studio /
Enterprise Manager can do this, but guess what they do behind the scenes?
Drop the table and re-create it.
"Hans" <goosseno@.gmail.com> wrote in message
news:5b95bb01-499a-410e-b656-cbe926f06263@.m34g2000hsb.googlegroups.com...
> Hello,
> I'm trying to do this:
> alter table maquinas add marca varchar(50) after modelo
> and I get the following error:
> Incorrect syntax near 'after'.
> What is going on?
> hans
|||Well, using Management Studio or Enterprise Manager is not that bad if your
table is small.
Ben Nevarez
although using Management Studio or Enterprise Manager is not that bad if
your table is small.
Ben
"Aaron Bertrand [SQL Server MVP]" wrote:

> No, you cannot tell SQL Server where to add a column. It gets apended to
> the "end". Why is column order important? Yes, Management Studio /
> Enterprise Manager can do this, but guess what they do behind the scenes?
> Drop the table and re-create it.
>
> "Hans" <goosseno@.gmail.com> wrote in message
> news:5b95bb01-499a-410e-b656-cbe926f06263@.m34g2000hsb.googlegroups.com...
>
>

Does SQL Server support "after" on alter table ?

Hello,
I'm trying to do this:
alter table maquinas add marca varchar(50) after modelo
and I get the following error:
Incorrect syntax near 'after'.
What is going on?
hansNo, you cannot tell SQL Server where to add a column. It gets apended to
the "end". Why is column order important? Yes, Management Studio /
Enterprise Manager can do this, but guess what they do behind the scenes?
Drop the table and re-create it.
"Hans" <goosseno@.gmail.com> wrote in message
news:5b95bb01-499a-410e-b656-cbe926f06263@.m34g2000hsb.googlegroups.com...
> Hello,
> I'm trying to do this:
> alter table maquinas add marca varchar(50) after modelo
> and I get the following error:
> Incorrect syntax near 'after'.
> What is going on?
> hans|||Well, using Management Studio or Enterprise Manager is not that bad if your
table is small.
Ben Nevarez
although using Management Studio or Enterprise Manager is not that bad if
your table is small.
Ben
"Aaron Bertrand [SQL Server MVP]" wrote:
> No, you cannot tell SQL Server where to add a column. It gets apended to
> the "end". Why is column order important? Yes, Management Studio /
> Enterprise Manager can do this, but guess what they do behind the scenes?
> Drop the table and re-create it.
>
> "Hans" <goosseno@.gmail.com> wrote in message
> news:5b95bb01-499a-410e-b656-cbe926f06263@.m34g2000hsb.googlegroups.com...
> > Hello,
> >
> > I'm trying to do this:
> > alter table maquinas add marca varchar(50) after modelo
> >
> > and I get the following error:
> > Incorrect syntax near 'after'.
> >
> > What is going on?
> >
> > hans
>
>

Sunday, March 25, 2012

Does SQL 2005 still support the *= syntax?

Does SQL Server 2005 still support the *= outer join syntax without having
to set the DB Compatibility switch? A friend of mine tested out SQL 2005
Beta 2 and said that *= was still supported, but then when the official SQL
2005 release came out, *= no longer worked without having to set the
compatibility switch. That seems like a HUGE change to make between the
last beta and the official release.AFAIK, this change was made around the June CTP timeframe. The answer is
no, there is no support for *= unless you're in 8.0 compatability mode (or
lower). Which, IMHO, is a great thing. That syntax has caused so many
problems over the years...
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Jay Sullivan" <jaysullivan@.nospam.nospam> wrote in message
news:e42BOS74FHA.2560@.TK2MSFTNGP12.phx.gbl...
> Does SQL Server 2005 still support the *= outer join syntax without having
> to set the DB Compatibility switch? A friend of mine tested out SQL 2005
> Beta 2 and said that *= was still supported, but then when the official
> SQL 2005 release came out, *= no longer worked without having to set the
> compatibility switch. That seems like a HUGE change to make between the
> last beta and the official release.
>

Friday, March 9, 2012

Does Debug > Build in Script Task actually do anything?

I'm looking for some way to verify the syntax, references, variables, etc. in my Script Tasks without having to run the package or the task.

There's a Build command in the Debug menu, but it doesn't seem to do anything -- certainly, not like the "Build Solution" in a Visual Studio project.

Am I missing something? Does Debug > Build in the VSA editor actually do anything?

Thanks!

- Mike

mike.groh wrote:

I'm looking for some way to verify the syntax, references, variables, etc. in my Script Tasks without having to run the package or the task.

There's a Build command in the Debug menu, but it doesn't seem to do anything -- certainly, not like the "Build Solution" in a Visual Studio project.

Am I missing something? Does Debug > Build in the VSA editor actually do anything?

Thanks!

- Mike

Mike,

I don't think it does for SSIS, no. This is a legacy from using someone else's IDE in order to facilitate scripting.

-Jamie

Tuesday, February 14, 2012

Do YOU see the syntax error?

Hey All,
I get error 170 on the select line(syntax) saying there is an error around the '='. To me this looks good, I must be missing something obvious - a second pair of eyes and maybe a working brain would really help me out - Thanks

DECLARE @.CylinderID int
DECLARE @.LocationID int
DECLARE @.CurrentLocID int

SELECT Distinct bl.[Date], i.BottleID = @.CylinderID, i.Loc_ID = @.LocationID
FROM [Bottle Location] bl, inserted i
WHERE bl.BottleID = i.BottleID
AND bl.[Date] = (SELECT max(bl.[DATE])
From [Bottle Location] bl, inserted i
WHERE bl.BottleID = i.BottleID)could you state exactly what are you trying to return here?

SELECT Distinct bl.[Date], i.BottleID = @.CylinderID, i.Loc_ID = @.LocationID

I get the feeling you are trying to return all rows where i.BottleID contains the same value as @.CylinderID and i.Loc_ID contains the same value as @.LocationID...|||Hey - I was trying to assign the value to the variables based on the most recent date in the location table for that cylinder. However, you were right, I wasn't writing it correctly. I re-wrote it and the syntax is good now. I'd still be sitting here though, so thanks for the comments. A second pair of eyes is sometimes the greatest help!|||Glad you got it straightened out!

Do While Loop in T-SQL?

Is there a way to construct a Do While Loop in T-SQL. I didn't see any =
syntax in BOL for doing this. Essentially, I want to always run the the =
loop once, then check the loop expression to see if I can exit. In VB =
it would look something like this
Do
..
Loop While(something < 5)
Thanks,
--MichaelWhile (something < 5)
Begin
..do stuff
End
HTH
Thomas
"Raterus" <raterus@.hotmail.com> wrote in message
news:uf9oXJSRFHA.2932@.TK2MSFTNGP09.phx.gbl...
Is there a way to construct a Do While Loop in T-SQL. I didn't see any synt
ax
in BOL for doing this. Essentially, I want to always run the the loop once,
then check the loop expression to see if I can exit. In VB it would look
something like this
Do
..
Loop While(something < 5)
Thanks,
--Michael|||Let me be a bit more descriptive, "something" is set from within the =
loop. What I'm trying to avoid is having to set "Something" before the =
loop, and also in the loop, repeating the exact same syntax. A normal =
While loop won't work without duplicating the code from within the loop.
Do
Something =3D GetSomething()
DoSomething(Something)
Loop While (Something < 5)
"Thomas" <replyingroup@.anywhere.com> wrote in message =
news:OWtdcLSRFHA.2356@.TK2MSFTNGP14.phx.gbl...
> While (something < 5)
> Begin
> ...do stuff
> End
>=20
>=20
> HTH
>=20
>=20
> Thomas
>=20
>=20
> "Raterus" <raterus@.hotmail.com> wrote in message=20
> news:uf9oXJSRFHA.2932@.TK2MSFTNGP09.phx.gbl...
> Is there a way to construct a Do While Loop in T-SQL. I didn't see =
any syntax=20
> in BOL for doing this. Essentially, I want to always run the the loop =
once,=20
> then check the loop expression to see if I can exit. In VB it would =
look=20
> something like this
>=20
> Do
> ...
> Loop While(something < 5)
>=20
> Thanks,
> --Michael=20
>=20
>|||That's not the same as a do/while loop - with a do/while loop (as shown, or
in the C languages) the code in the loop runs at least once. A couple option
s:
1. Change your condition so it will always be true the first time; to
continue your example:
WHILE (something < 6) BEGIN ... END
2. Move the condition to an IF statement at the end of the loop:
WHILE (1=1)
BEGIN
-- code...
IF (something = 5) BREAK
END
3. Use a GOTO statement:
_LOOP:
-- ... CODE
IF (something < 5) GOTO _LOOP
"Thomas" wrote:

> While (something < 5)
> Begin
> ...do stuff
> End
>
> HTH
>
> Thomas
>
> "Raterus" <raterus@.hotmail.com> wrote in message
> news:uf9oXJSRFHA.2932@.TK2MSFTNGP09.phx.gbl...
> Is there a way to construct a Do While Loop in T-SQL. I didn't see any sy
ntax
> in BOL for doing this. Essentially, I want to always run the the loop onc
e,
> then check the loop expression to see if I can exit. In VB it would look
> something like this
> Do
> ...
> Loop While(something < 5)
> Thanks,
> --Michael
>
>|||That's an odd design pattern - declaring the variable for the exit condition
within the loop. If both GetSomething() and DoSomething(Something) are
deterministic then the condition will either always be false in which case
there's no reason to have it, or always be true in which case the loop will
never exit.
"Raterus" wrote:

> Let me be a bit more descriptive, "something" is set from within the loop. What I
'm trying to avoid is having to set "Something" before the loop, and also in the loo
p, repeating the exact same syntax. A normal While loop won't work without duplicat
ing
the code from within the loop.
> Do
> Something = GetSomething()
> DoSomething(Something)
> Loop While (Something < 5)
> "Thomas" <replyingroup@.anywhere.com> wrote in message news:OWtdcLSRFHA.235
6@.TK2MSFTNGP14.phx.gbl...
>|||Just an example off the top of my head, can't say it makes any sense to =
me either, the main thing I wanted was a loop that runs at least once.
"KH" <KH@.discussions.microsoft.com> wrote in message =
news:0DF4A1CF-94E9-4839-8624-DE769BCAE747@.microsoft.com...
> That's an odd design pattern - declaring the variable for the exit =
condition=20
> within the loop. If both GetSomething() and DoSomething(Something) are =

> deterministic then the condition will either always be false in which =
case=20
> there's no reason to have it, or always be true in which case the loop =
will=20
> never exit.=20
>=20
>=20
> "Raterus" wrote:
>=20
loop. What I'm trying to avoid is having to set "Something" before the =
loop, and also in the loop, repeating the exact same syntax. A normal =
While loop won't work without duplicating the code from within the loop.
news:OWtdcLSRFHA.2356@.TK2MSFTNGP14.phx.gbl...
any syntax=20
loop once,=20
would look=20|||Thanks, I had always "hacked" around it using methods like this. Just =
wanted to make sure I wasn't missing anything syntactically.
"KH" <KH@.discussions.microsoft.com> wrote in message =
news:0C77E8A0-3E6D-4C1D-A339-2040364DE56B@.microsoft.com...
> That's not the same as a do/while loop - with a do/while loop (as =
shown, or=20
> in the C languages) the code in the loop runs at least once. A couple =
options:
>=20
> 1. Change your condition so it will always be true the first time; to=20
> continue your example:
> WHILE (something < 6) BEGIN ... END
>=20
> 2. Move the condition to an IF statement at the end of the loop:
> WHILE (1=3D1)
> BEGIN
> -- code...
> IF (something =3D 5) BREAK
> END
>=20
> 3. Use a GOTO statement:
>=20
> _LOOP:
> -- ... CODE
> IF (something < 5) GOTO _LOOP
>=20
>=20
>=20
> "Thomas" wrote:
>=20
any syntax=20
loop once,=20
look=20|||Declare @.Done TinyInt Set @.Done = 0
While @.Done = 0 Begin
-- Do some work here
If GetSomething() = 'done' Set @.Done =1
End
"Raterus" wrote:

> Just an example off the top of my head, can't say it makes any sense to me
either, the main thing I wanted was a loop that runs at least once.
> "KH" <KH@.discussions.microsoft.com> wrote in message news:0DF4A1CF-94E9-48
39-8624-DE769BCAE747@.microsoft.com...
ing the code from within the loop.
>