Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Columns named BEGIN and END

Author  Topic 

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-03-27 : 15:26:14
Just curious.

In the 25 gazillion Insert Into statements i do every day, i have to bracket our columns that are titled [BEGIN] and [END] because SSMS gets confused. In what capacity in a query would the statements BEGIN and END be used where they are not column names?

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2012-03-27 : 15:34:41
Many ways. Here's one:
IF OBJECT_ID('MyTable') IS NOT NULL
BEGIN
Drop Table MyTable
END


BEGIN/END is structural code.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-27 : 15:34:53
IF EXISTS(SELECT * FROM TABLE)
BEGIN
..sql
..sql
..sql
END


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-27 : 15:35:37
Was this your Guru who named their Columns BEGIN and END?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-27 : 15:36:53
See http://msdn.microsoft.com/en-us/library/ms190487.aspx

For example:
DECLARE @i INT = 20;

IF (@i < 10)
BEGIN
PRINT 'line 1';
PRINT 'line 2';
END
ELSE
BEGIN
PRINT 'line3';
PRINT 'line4';
END


Then again
And one more time
Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-03-27 : 15:37:41
Brett: don't get me started. I have to censor myself too frequently as it is. Eeesh.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2012-03-27 : 15:39:56
quote:
Originally posted by sunitabeck

See http://msdn.microsoft.com/en-us/library/ms190487.aspx

For example:
DECLARE @i INT = 20;

IF (@i < 10)
BEGIN
PRINT 'line 1';
PRINT 'line 2';
END
ELSE
BEGIN
PRINT 'line3';
PRINT 'line4';
END


Then again
And one more time



lol. that's a lotta yaks

quote:
Originally posted by X002548

Was this your Guru who named their Columns BEGIN and END?

Brett

Other columns named ORDER, INT, CREATE...
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-27 : 15:50:27
quote:
Originally posted by WJHamel

Brett: don't get me started. I have to censor myself too frequently as it is. Eeesh.



That's what the Corral is for

http://www.sqlteam.com/forums/forum.asp?FORUM_ID=15



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

WJHamel
Aged Yak Warrior

651 Posts

Posted - 2012-03-27 : 15:53:07
yeah, until some engineer, dba, or support person in my building stumbles upon my post. Then i get that ominous instant message. "Come see me in my office NOW". I walk into my boss's office and see "SQLTEAM.COM" up on his screen.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-27 : 15:54:22
hey..then maybe they'd start learning something

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -