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


Querying the INFORMATION_SCHEMA


Querying the INFORMATION_SCHEMA

Author
Message
Wyatt Winghead
Wyatt Winghead
Valued Member
Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)

Group: General Forum Members
Points: 62 Visits: 57
It appears that whatever you hightlight is passed to the stored procedure as a single string. It doesn't parse out commas, and positively objects to quotes.
So I bent to the wind, and simply parsed out the values from the single input parameter. This makes it uglier to use when not using the keyboard shortcut, but when will that happen?

Cheers!
Mike DiRenzo
Mike DiRenzo
SSC-Enthusiastic
SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)

Group: General Forum Members
Points: 155 Visits: 210
Yes, indeed, it treats the whole comma delim'd parameter as a string - BUT ONLY IN SSMS.

It works perfectly in SQA. I can't figure out why. One forum poster said it worked for him in SSMS.
kevriley
kevriley
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2751 Visits: 2606
Mike DiRenzo (3/10/2008)
One forum poster said it worked for him in SSMS.


Yes and it still does!...
even with multiple parameters and ones delimited by single quotes

create proc kev_test
(
@param1 varchar(50),
@param2 varchar(50)
)
as set nocount on
select 'the first parameter is ' + @param1 + ' the second is ' + @param2



assign Ctrl-5 to kev_test

new window..

'first param','second param'


highlight it, press Ctrl-5 and results are
the first parameter is first param the second is second param


Wyatt Winghead
Wyatt Winghead
Valued Member
Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)

Group: General Forum Members
Points: 62 Visits: 57
Definitely there's some option/setup in SSMS -- even on the builtins, if I put single quotes around the string and press Alt-F1, it gives me the error:

Incorrect syntax near 'sp_help'.

I wouldn't have a clue where to go from that, though. MSDN Help has, as it often is, been unhelpful, and I haven't found the magic words for Google.
Wyatt Winghead
Wyatt Winghead
Valued Member
Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)

Group: General Forum Members
Points: 62 Visits: 57
Microsoft SQL Server Management Studio 9.00.1399.00
Microsoft Analysis Services Client Tools 2005.090.1399.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 7.0.5730.11
Microsoft .NET Framework 2.0.50727.832
Operating System 5.1.2600 (XP Pro 2002 SP2)
kevriley
kevriley
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2751 Visits: 2606
looks like you haven't applied SP2 to your client tools

Microsoft SQL Server Management Studio 9.00.3042.00
Microsoft Analysis Services Client Tools 2005.090.3042.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 7.0.5730.13
Microsoft .NET Framework 2.0.50727.1433
Operating System 5.1.2600
Mike DiRenzo
Mike DiRenzo
SSC-Enthusiastic
SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)

Group: General Forum Members
Points: 155 Visits: 210
I have other similar macro scripts that work in SQA and not SSMS. It has been really frustrating not to be able to use them effectively in SSMS - especially if you are a type and typo centric TSQL'r.

I will apply SP2 and see if it works. Thanks for the posts and the insight re: SP2.

-Mike
Wyatt Winghead
Wyatt Winghead
Valued Member
Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)

Group: General Forum Members
Points: 62 Visits: 57
That does the trick!
Thanks!
Andrew_Webster
Andrew_Webster
SSC-Enthusiastic
SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)SSC-Enthusiastic (128 reputation)

Group: General Forum Members
Points: 128 Visits: 32
Top tip for working with the INFORMATION_SCHEMA views: use Excel to view them.

In Excel, go to Data, Import External Data..., then either Import Data or New Database Query. Use or create a DSN and fish out the INFORMATION_SCHEMA view that your interested in. COLUMNS is the one I use the most.

Then use Excel's Autofilter and you got yourself a Data Dictionary that you can filter to find, say, all fields with the same name, all fields of the same datatype (use char instead of nchar and have a feeling you've done it somewhere else too?), or whatever.



Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45127 Visits: 39922
Andrew_Webster (3/18/2008)
Top tip for working with the INFORMATION_SCHEMA views: use Excel to view them.

In Excel, go to Data, Import External Data..., then either Import Data or New Database Query. Use or create a DSN and fish out the INFORMATION_SCHEMA view that your interested in. COLUMNS is the one I use the most.

Then use Excel's Autofilter and you got yourself a Data Dictionary that you can filter to find, say, all fields with the same name, all fields of the same datatype (use char instead of nchar and have a feeling you've done it somewhere else too?), or whatever.


Hadn't thought about that... that's a very clever and useful idea! Thanks, Andrew!

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
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