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


Search anything anywhere


Search anything anywhere

Author
Message
Florian Reischl
Florian Reischl
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2197 Visits: 3934
Comments posted to this topic are about the item Search anything anywhere


The more I learn, the more I know what I do not know
Blog: Things about Software Architecture, .NET development and T-SQL

How to Post Data/Code to get the best Help How to Post Performance Problems
JacekO
JacekO
Mr or Mrs. 500
Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)

Group: General Forum Members
Points: 507 Visits: 606
Thanks Florian for a buggy script. That thing just fried my server. Angry

---------------------------------------------
Nothing is impossible.
It is just a matter of time and money.

Florian Reischl
Florian Reischl
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2197 Visits: 3934
Hi JacekO

What is the problem?

Greets
Flo


The more I learn, the more I know what I do not know
Blog: Things about Software Architecture, .NET development and T-SQL

How to Post Data/Code to get the best Help How to Post Performance Problems
JacekO
JacekO
Mr or Mrs. 500
Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)

Group: General Forum Members
Points: 507 Visits: 606
No problem, great script.
I could not resist the temptation and was trying to play an April's Fool joke on you. :-D

Thanks.

---------------------------------------------
Nothing is impossible.
It is just a matter of time and money.

Florian Reischl
Florian Reischl
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2197 Visits: 3934
Dang! You got me! :-D

I really feared that something might be damaged and started to review the script...!

Have a nice day ;-)
Flo


The more I learn, the more I know what I do not know
Blog: Things about Software Architecture, .NET development and T-SQL

How to Post Data/Code to get the best Help How to Post Performance Problems
smurphy-995925
smurphy-995925
SSC Veteran
SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)SSC Veteran (208 reputation)

Group: General Forum Members
Points: 208 Visits: 87
It is a really nice script for SQL 2005 and SQL 2008 but it doesn't work in SQL 2000. Maybe that should be noted somewhere.

And I really like you Garfield. It is first thing in the morning here in AZ and he looks the way I feel!
thermanson
thermanson
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 287
This is a good script. I had a use for something similar some time ago and created the sproc below with some additional parameters to limit searches.

 

Create Procedure [dbo].[sp_ColumnValues]
@iTableName varchar(100),
@iColumnName varchar(100),
@iWhere varchar(100),
@idataType varchar(100),
@ivalue varchar(100)

as
/*

Requires following inputs:

@iTableName - Table to be searched. Use wildcard '%' to search all tables.
@iColumnName - Column to be searched. Use wildcard '%' to search all Columns.
Unlikely to work when searching multiple tables.
@iWhere - Criteria to restrict results. Use the operator "in" to select multiple results.
Use an expression that is always true such as 1 = 1 to get all results.
This may result in a very long running query.
Unlikely to work when searching multiple tables.
@idataType - use this value to only search certain datatype ("int","char","decimal","smalldatetime")
Use wildcard '%' to search all datatypes.
@ivalue - value to be search for. Can use wildcards to broaden search.

Example

EXECUTE [MISDB].[dbo].[sp_ColumnValues]
@iTableName = 'accounts'
,@iColumnName = '%'
,@iWhere = 'acct_nbr = 99999999'
,@idataType = 'decimal'
,@ivalue = '''%.62'''

*/

If Len(@iTableName) = 0 set @iTableName = '%'
If Len(@iColumnName) = 0 set @iColumnName = '%'

IF OBJECT_ID (N'tempdb.dbo.#Tables',N'U' ) IS NOT NULL
Begin
Drop Table #Tables
End

Create Table #Tables(
TABLE_Qualifier varchar(100),
Table_Owner varchar(100),
Table_Name varchar(100),
Table_Type varchar(100),
Remarks varchar(100))


insert #Tables Exec sp_Tables

IF OBJECT_ID (N'tempdb.dbo.##Columns',N'U' ) IS NOT NULL
Begin
Drop Table ##Columns
End

Create Table ##Columns(
TABLE_QUALIFIER sysname,
TABLE_OWNER sysname,
TABLE_NAME sysname,
COLUMN_NAME sysname,
DATA_TYPE smallint,
TYPE_NAME sysname,
iPRECISION int,
LENGTH int,
SCALE smallint,
RADIX smallint,
NULLABLE smallint,
REMARKS varchar(254),
COLUMN_DEF nvarchar(4000),
SQL_DATA_TYPE smallint,
SQL_DATETIME_SUB smallint,
CHAR_OCTET_LENGTH int,
ORDINAL_POSITION int,
IS_NULLABLE varchar(254),
SS_DATA_TYPE tinyint)



DECLARE @getTableID CURSOR
DECLARE @TableName varchar(100)

SET @getTableID = CURSOR FOR
SELECT Table_Name
FROM #Tables
Where Table_Type = 'TABLE' and Table_Name like @iTableName
OPEN @getTableID

FETCH NEXT FROM @getTableID INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN

insert ##Columns Exec sp_Columns @table_name = @TableName

FETCH NEXT FROM @getTableID INTO @TableName
END

CLOSE @getTableID
DEALLOCATE @getTableID

DECLARE @SqlStatement nvarchar(4000)

IF OBJECT_ID (N'tempdb.dbo.##ColumnValues',N'U' ) IS NOT NULL
Begin
Drop Table ##ColumnValues
End

Create Table ##ColumnValues(
cValue varchar(100),
ColumnName varchar(100))

DECLARE @getValueID CURSOR
DECLARE @vcolumn varchar(100)
Declare @vTable varchar(100)

SET @getValueID = CURSOR FOR
SELECT Column_Name,Table_Name
from ##Columns
Where Column_Name like @iColumnName and Type_Name like @iDataType

OPEN @getValueID

FETCH NEXT FROM @getValueID INTO @vColumn,@vTable

WHILE @@FETCH_STATUS = 0
BEGIN

Select @SqlStatement =
'Insert Into ##ColumnValues
Select Convert(varchar(100),' + @vColumn + ') , ''' + @vColumn + ''' From ' + @vTable + ' Where ' + @iWhere

--Select @SqlStatement
EXEC sp_executesql @SqlStatement

FETCH NEXT FROM @getValueID INTO @vColumn,@vTable
END

CLOSE @getValueID
DEALLOCATE @getValueID

-- Return columns that match criteria

Select @SqlStatement = '
Select *
From ##ColumnValues
Where cvalue like ' + @ivalue

EXEC sp_executesql @SqlStatement


Florian Reischl
Florian Reischl
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2197 Visits: 3934
Hi thermanson

So why don't you publish it here? ;-)

My script was only a simple helper I wrote sometime. Since now several people within my company asked for it, so I thought there might be somebody else who may need it.

Greets
Flo


The more I learn, the more I know what I do not know
Blog: Things about Software Architecture, .NET development and T-SQL

How to Post Data/Code to get the best Help How to Post Performance Problems
Madhu R
Madhu R
Grasshopper
Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)

Group: General Forum Members
Points: 14 Visits: 43
Hi,

I got some errors are prompted when I run this script. And I am using 2K8 SE

Msg 2715, Level 16, State 3, Line 81
Column, parameter, or variable #1: Cannot find data type SYSNAME.
Parameter or variable '@column' has an invalid data type.
Msg 2715, Level 16, State 3, Line 81
Column, parameter, or variable #3: Cannot find data type SYSNAME.
Parameter or variable '@schema' has an invalid data type.
Msg 2715, Level 16, State 3, Line 81
Column, parameter, or variable #4: Cannot find data type SYSNAME.
Parameter or variable '@table' has an invalid data type.

Please assist
Florian Reischl
Florian Reischl
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2197 Visits: 3934
Hi Madhu

Try to replace all "SYSNAME" data types with "NVARCHAR(128)".

Greets
Flo


The more I learn, the more I know what I do not know
Blog: Things about Software Architecture, .NET development and T-SQL

How to Post Data/Code to get the best Help How to Post Performance Problems
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