473,466 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL Server Stored Procedure

296 Contributor
The below is an Oracle Stored procedure -->

Expand|Select|Wrap|Line Numbers
  1. create or replace function search_in_table(
  2.  
  3.             owner varchar2,
  4.  
  5.             table_name varchar2,
  6.  
  7.             search_string varchar2)
  8.  
  9.             return varchar2 is
  10.  
  11.             stmt varchar2(32700);
  12.  
  13.             col varchar2(32700);
  14.  
  15. begin
  16.  
  17.             stmt := 'select ';
  18.  
  19.             for c in (
  20.  
  21.                         select column_name
  22.  
  23.                         from all_tab_columns
  24.  
  25.                         where all_tab_columns.table_name=search_in_table.table_name
  26.  
  27.                                     and all_tab_columns.owner=search_in_table.owner
  28.  
  29.                                     and data_type like '%CHAR%' )
  30.  
  31.             loop
  32.  
  33.                         stmt := stmt || 'max(case when REGEXP_LIKE("' || c.column_name ||  '", ''' || search_string || ''') then ''' || c.column_name || ' ''' || ' else null end) || ';
  34.  
  35.             end loop;
  36.  
  37.             stmt:= stmt||'nvl2(count(*),null,null) from "'||owner||'"."'||table_name||'"';
  38.  
  39.             execute immediate stmt into col;
  40.  
  41.             return col;
  42.  
  43. end;

The below Query uses the above function -->

Expand|Select|Wrap|Line Numbers
  1. select table_name,cols from (
  2.  
  3.             select rownum,
  4.  
  5.             table_name,
  6.  
  7.             search_in_table('SYSMAN',table_name,'[[:digit:]]') cols
  8.  
  9.             from all_tables where owner='SYSMAN' and tablespace_name='SYSTEM')
  10.  
  11.             where cols is not null;

Please convert the function and the Query to SQL Server Stored Procedure and Query respectively.
May 2 '08 #1
1 1240
debasisdas
8,127 Recognized Expert Expert
Please find related discussion here .
May 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Yves Touze | last post by:
Hi All, I'm trying to migrate from SQL Server 7.0 to SQL Server 2000. I've got some ASP page which call VB components that retrieve shaped recordsets from SQL Server using the MSDATASHAPE...
3
by: Michael | last post by:
This one's really got me. I have a VB.NET (version 1.1.4322) project that provides an easy way to execute stored procedures on a generic level. When I run the code on computer A (running SQL...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
5
by: gilles27 | last post by:
I've ready many of the posts on this and other newsgroups in which people describe working practices for source control of database scripts. We are looking to implement something similar in my...
26
by: David W. Fenton | last post by:
A client is panicking about their large Access application, which has been running smoothly with 100s of thousands of records for quite some time. They have a big project in the next year that will...
4
by: Bill Sonia | last post by:
Hello, I have a Widnows Service that creates a system event that I would like to have a Sql Server stored procedure fire when the stored procedure is called. I have a Windows Service that runs...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.