Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Variable Array Table


Variable Array Table

Author
Message
Hardy21
Hardy21
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1204 Visits: 1399
Trick question but confused with explanation & query posted in the answer because it throws an error. Thanks Hugo for explanation. I learn usage of delimiters.

Thanks
Carlo Romagnano
Carlo Romagnano
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3627 Visits: 3236
Obvious! In the daily work you do not need a special syntax. But, sometime my clients ask me for something special. And thanks to the delimiter I can extract data and send them without writing an application outside sqlserver.
In the example, unfortunately, most of syntax has been lost because of html tag.
So, I provide another simplest one. The following script build syntax to expand sp, functions or views, comment or uncomment the type of object and substitute %my_proc% with the name of object, run it and than select all the result copy and paste and execute in the query window.

set nocount on
select 'exec sp_helptext ' AS [--],o.name
from sysobjects o(readuncommitted)
where o.xtype IN(''
,'P '--: stored procedure'
--,'IF'--: inline function'
--,'FN'--: scalar function'
--,'TF'--: table function'
--,'V '--: view'
--,'TR'--: trigger'
)
and o.name like '%my_proc%'
and o.name not like 'dt[_]%'
order by o.Name
set nocount off

At last, the 84% of users learned 3 new things:
1) Read carefully the Qotd.
2) Use of delimiter.
3) Only lack of fantasy is the limit.
vk-kirov
vk-kirov
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3494 Visits: 4408
Carlo Romagnano (10/13/2010)
In the example, unfortunately, most of syntax has been lost because of html tag.

Could you please zip that script and attach it to your next message? :-)
ziangij
ziangij
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2911 Visits: 374
thanks Hugo... :-)

Hugo Kornelis (10/12/2010)
I got two points for answering a question that tests no useful skill whatsoever? Come on, Steve! Even one point would have been more than enough for this one!

Carlo, thanks for the effort of submitting a QotD (not cynical!). But next time, please submit a question about something that actually has any real use for SQL Server professionals.
I can imagine someone accidentally not matching opening and closing brackets (especially if []] is used somewhere in the bracketed text). But then also having an extraneous closing bracket in another batch, that is sent at the same time, and with code after that bracket that "just happens" to make the original code complete so that no error is thrown? The chance of that happening anytime, anywhere, is infenitely small. So noone will learn anything useful from this question.
Since you obviously (based on the explanation) wanted to educate visitors of this site about the usefulness of using brackets to delimit identifiers, you should have submitted a question that did just that, instead of deliberately adding nonsensical code to ensure as little people as possible get it right. The aim of this site should not be to get as many people as possible to fail, but to show as many people as possible the great stuff SQL Server can do.

ElectricHobo
ElectricHobo
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 5
deleteme
SQLRNNR
SQLRNNR
SSC-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21113 Visits: 18259
Thanks for the question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

natalie.ignatieva
natalie.ignatieva
SSC Veteran
SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)

Group: General Forum Members
Points: 272 Visits: 438
Management studio shows me this script mostly in black meaning there is something wrong in the script even if it's completed successfully. I guess even colorblind people can see it. I don't see the point of this question. I hope nobody will post these kind of 'questions' any more. It's not CS spirit.
Hugo Kornelis
Hugo Kornelis
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8339 Visits: 11585
natalie.ignatieva (10/27/2010)
Management studio shows me this script mostly in black meaning there is something wrong in the script even if it's completed successfully.

The color coding is actually correct. The first [ character starts a table name that only ends at the final ], so everything in between them is part of the table name. Black is the default color used for (a.o.) table names.
Please read the rest of the discussion for a more comprehensive explanation (and for many people agreeing with our dislike of the question)


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
natalie.ignatieva
natalie.ignatieva
SSC Veteran
SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)SSC Veteran (272 reputation)

Group: General Forum Members
Points: 272 Visits: 438

The color coding is actually correct. The first [ character starts a table name that only ends at the final ], so everything in between them is part of the table name. Black is the default color used for (a.o.) table names.
Please read the rest of the discussion for a more comprehensive explanation (and for many people agreeing with our dislike of the question)


Yes, the color is correct, but I didn't have a chance to copy the script, so I had to type it. I missed ] in the line with 'while' because you don't expect developers to create tables with such weird names and thought it was typo or something. but even if I didn't miss it and executed the statement, I would see that author just wanted to create a table with such weird name. My point is that if you have your app generating these kind of statements and you try to understand what actually is wrong (yes, author wanted to look us for some errors in the script as if it's supposed actually run infinite loop or begin transaction), anyway you copy it from profiler to studio, see 'BEGIN' and 'INSERT' in black and just then you look for syntax issues.
As I understand the point of this question is to make us develop skills in typing scripts from the image and don't make errors, right? I failed. Am I a bad SQL developer after that?
Hugo Kornelis
Hugo Kornelis
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8339 Visits: 11585
natalie.ignatieva (10/27/2010)
As I understand the point of this question is to make us develop skills in typing scripts from the image and don't make errors, right? I failed. Am I a bad SQL developer after that?

No. I fully agree with you that this question is totally useless.


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search