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


Search in your T-SQL objects


Search in your T-SQL objects

Author
Message
Wilfred van Dijk
Wilfred van Dijk
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1405 Visits: 1359
Comments posted to this topic are about the item Search in your T-SQL objects

Wilfred
The best things in life are the simple things
JStiney
JStiney
SSC Journeyman
SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)

Group: General Forum Members
Points: 95 Visits: 446
Wilfred,
I get the following message on the select statement when I inserted
set @SearchCriteria = '%MEAG_MASTER%' and executed the script.
Any suggestions?

Msg 170, Level 15, State 1, Line 5
Line 5: Incorrect syntax near ' '.

Line 5 is the select.



rVadim
rVadim
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1123 Visits: 2305
I've got that error too. When pasted in Notepad++ it looks like this:

select????distinct
????????@SearchCriteria as ZoekCriteria
????????, 'in code' as Classification
????????, b.type_desc
????????, object_name(a.id) "ObjectName"
????????, b.modify_date
from????syscomments a
inner????join sys.objects b
on????????a.id = b.object_id
where????a.encrypted = 0
and????????a.text like @SearchCriteria


--Vadim.
JStiney
JStiney
SSC Journeyman
SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)

Group: General Forum Members
Points: 95 Visits: 446
Thanks rVadim,
I changed the ??? to blanks and the script works for me.

declare @SearchCriteria nvarchar(100)

set @SearchCriteria = '%MEAG_MASTER%' ---------> enter criteria here

select distinct
@SearchCriteria as ZoekCriteria
, 'in code' as Classification
, b.type_desc
, object_name(a.id) "ObjectName"
, b.modify_date
from syscomments a
inner join sys.objects b
on a.id = b.object_id
where a.encrypted = 0
and a.text like @SearchCriteria
union
select @SearchCriteria
, 'in code' as Classification
, 'SYNONYM'
, name
, modify_date
from sys.synonyms
where base_object_name like @SearchCriteria
union
select @SearchCriteria
, 'in code' as Classification
, 'CHECK_CONSTRAINT'
, name
, modify_date
from sys.check_constraints
where definition like @SearchCriteria
union
select @SearchCriteria
, 'in code' as Classification
, 'DEFAULT_CONSTRAINT'
, name
, modify_date
from sys.default_constraints
where definition like @SearchCriteria
union
select @SearchCriteria
, 'as columnname' as Classification
, 'COLUMN'
, object_name(object_id) collate database_default
, NULL
from sys.columns
where name like @SearchCriteria
union
select @SearchCriteria
, 'in objectname' as Classification
, type_desc collate database_default
, name collate database_default
, modify_date
from sys.objects
where name like @SearchCriteria
order by 1,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