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

Home Posts Topics Members FAQ

Where is error-I need exec in function - result is without error,but not return data

1 New Member
create function dbo.fnc_varchar_columns_alltrim
()
returns @vysledek table
( tabulka sysname null,
sloupec sysname null,
pocet_zaznamu int null,
datovy_typ varchar(256) null
)
as

begin

declare @sql_text nvarchar(2000),
@table_name varchar(256),
@column_name varchar(256),
@dat_typ varchar(256),
@celkem int,
@int_objSQL int,
@int_erros int,
@int_objSelectCountResult int,
@bint_SelectCount bigint


declare @cislo table
( pocet int
)

declare @pom table
( table_name sysname,
column_name sysname,
datovy_typ varchar(256)
)

insert into @pom
select o.name as table_name, c.name as column_name, t.name as datovy_typ
from sys.objects o
left join sys.columns c on c.object_id = o.object_id
left join sys.types t on t.user_type_id = c.user_type_id
where o.type = 'U' and o.name not in ('cVykazPriloha','cVysledovka','cRozvaha','dtprope rties') and o.name not like 'rep%'
and c.user_type_id in (167,231) and c.name not in ('key')
and o.name = 'adm_DB_version' and c.name = 'version'
order by o.name

while exists (select 1 from @pom)
begin
select top 1 @table_name=table_name,@column_name=column_name,@d at_typ=datovy_typ from @pom
delete from @cislo
exec @int_erros = sp_OACreate 'SQLDMO.SQLServer', @int_objSQL OUTPUT
exec @int_erros = sp_OASetProperty @int_objSQL, 'LoginSecure', TRUE
exec @int_erros = sp_OAMethod @int_objSQL, 'Connect', null, '.'
set @sql_text = 'select count(*) from dbo.' + @table_name + ' where len(' + @column_name+ ') <> len(ltrim(rtrim(' + @column_name+ ')))'
set @sql_text = 'ExecuteWithResults("' + @sql_text + '")'
exec @int_erros = sp_OAMethod @int_objSQL, @sql_text, @int_objSelectCountResult OUTPUT
exec @int_erros = sp_OAMethod @int_objSelectCountResult, 'GetRangeString(1, 1)', @bint_SelectCount OUT
exec @int_erros = sp_OADestroy @int_objSQL
set @celkem = @bint_SelectCount
if @int_erros <> 0
exec sp_OAGetErrorInfo @int_objSQL
if @celkem > 0
insert into @vysledek (tabulka,sloupec,pocet_zaznamu,datovy_typ) values (@table_name,@column_name,@celkem,@dat_typ)
delete top (1) from @pom
end

return

end

go
Sep 3 '09 #1
0 1997

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

Similar topics

7
by: diroddi | last post by:
I am having a problem using a dynamic where clause. I have a feeling that I am overlooking something very simple, although I can't seem to figure it out. The error i'm getting is: You have an...
5
by: windandwaves | last post by:
Hi Folk I was wondering if it is possible to find out what people click on, using PHP. For example, I have a PHP page with an email link and some third party links (e.g....
47
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
3
by: KathyB | last post by:
Hi, I have 2 tables: tblStations StationID Station tblStationUser RecordID UserName Station I'm trying to come up with a dataset that contains the
7
by: John | last post by:
Hi, How do websites like google page through large numbers of records? For example; if I do a search on Google, get 187,000 matches, and go to the 22nd page of the results; I'm sure Google...
6
by: Roy Gourgi | last post by:
Hi, I am trying to add a row to my table but I get the error message "invalid column name SOBN and BN1" on this statement. Basically, I am trying to add the row into the same table that I am...
2
by: Pavel Stehule | last post by:
Hello, Pg make query 1. and 2. very fast (use index), but for query 3. dont use index. I can solve its using select union, but I readed so pg 7.5 don't problem with OR operator. I use cvs pg. I...
5
by: Silvio Matthes | last post by:
Hello, I'm new to the list and did not find a suitable answer to my question so here it is: I try to select the rows of a table where the content of a varchar-column is empty ('') and...
4
by: Phillip Vong | last post by:
I'm a newbie using VS2005 to learn and test. I'm testing against the Northwind DB. I created a simple variable called "myVariable" and I assigned it the character "c". I want my SQL query to use...
9
by: Emin | last post by:
Dear Experts, I have a fairly simple query in which adding a where clause slows things down by at least a factor of 100. The following is the slow version of the query ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.