SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how can i restrict the query on query window that contain *(astric)


how can i restrict the query on query window that contain *(astric)

Author
Message
kumar4ashwani
kumar4ashwani
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 149
how can i restrict the query on query window that contain *(astric)


EXP:-
select * from emp
want to stop this king of query,only for the selected column should be allow.
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26313 Visits: 17553
kumar4ashwani (4/23/2014)
how can i restrict the query on query window that contain *(astric)


EXP:-
select * from emp
want to stop this king of query,only for the selected column should be allow.


Short answer...you can't.

You could jump through a lot of hoops and setup database triggers and all sorts of crazy stuff to try to prevent it but it is only going to slow down the whole system.

Honestly there is nothing wrong select * when used appropriately (like inside an exists). It is however terrible when used to shortcut building the list of columns which is what you are trying to prevent.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Steve Hall
Steve Hall
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: 2833 Visits: 11569
There was an article on this quite some time back: http://www.sqlservercentral.com/articles/SELECT+*/68324/.

Steve Hall
Linkedin
Blog Site
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26313 Visits: 17553
BrainDonor (4/23/2014)
There was an article on this quite some time back: http://www.sqlservercentral.com/articles/SELECT+*/68324/.


Just shoot me if I ever work in a place that uses that implementation!!! Even the author agrees it is pretty horrible to work with. ;-)

It is a novel approach however.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Luis Cazares
Luis Cazares
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16701 Visits: 19108
I can understand the need to prevent the use in production code, but not in ad-hoc queries when developing and testing (I often use it to evaluate a table structure).
You could have a code review policy and prevent changes to stored procedures, functions and views that won't comply with company standards. You could use tools such as Microsoft SQL Server Data Tools, SQLCop, SQL Code Guard or SQL Enlight to review the code (I couldn't find the right product from Red Gate, would it be Code Guard?).


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
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