Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««12345»»

Variable Array Table Expand / Collapse
Author
Message
Posted Tuesday, October 12, 2010 10:31 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 6:54 AM
Points: 1,032, Visits: 1,295
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
Post #1003347
Posted Wednesday, October 13, 2010 1:12 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 6:24 AM
Points: 2,451, Visits: 2,342
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.
Post #1003387
Posted Wednesday, October 13, 2010 1:56 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, May 9, 2014 12:47 AM
Points: 3,448, Visits: 4,407
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?
Post #1003399
Posted Wednesday, October 13, 2010 2:39 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, June 30, 2014 2:51 AM
Points: 1,972, Visits: 369
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.


Post #1003424
Posted Thursday, October 14, 2010 10:56 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 14, 2010 11:18 PM
Points: 1, Visits: 5
deleteme
Post #1004901
Posted Monday, October 18, 2010 10:18 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 7:37 PM
Points: 21,215, Visits: 14,917
Thanks for the question.



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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1006350
Posted Wednesday, October 27, 2010 3:04 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 5:46 PM
Points: 271, Visits: 369
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.
Post #1011905
Posted Wednesday, October 27, 2010 3:36 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:10 AM
Points: 5,917, Visits: 8,171
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
Post #1011918
Posted Wednesday, October 27, 2010 3:54 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 5:46 PM
Points: 271, Visits: 369

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?
Post #1011927
Posted Wednesday, October 27, 2010 4:30 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:10 AM
Points: 5,917, Visits: 8,171
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
Post #1011938
« Prev Topic | Next Topic »

Add to briefcase «««12345»»

Permissions Expand / Collapse