Anyone Heard Of Product For Sqls Called MyDTS?
Oct 14, 2005Who makes this? It's some sort of dts writer/scheduler I think.
View 1 RepliesWho makes this? It's some sort of dts writer/scheduler I think.
View 1 Replies(Spam Removed)
View 6 Replies View RelatedHi ,
I have created in my sqlserver 2005 database a stored procedure with the following code.
///////////////////////////////////////////////////////////////
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[d_sty_print_menu_per_role_per_app2]
@menu_name VARCHAR(255) = NULL ,
@is_user VARCHAR(255) = NULL ,
@is_appl VARCHAR(255) = NULL
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
;WITH GetHierarchy (item_text ,orden , read_order, item_parent , menu_item , enabled)
AS
(--Anchor.
select tb1.item_text, tb1.orden, tb1.read_order, tb1.item_parent , tb1.menu_item ,
(SELECT 'N' FROM PROFILE_PERMISSION PP
INNER JOIN sys_menu_item ON PP.MENU_ITEM=sys_menu_item.menu_item
WHERE PP.PROFILE_INDEX in (select up.profile_index from user_profile up where up.user_id= @is_user) and
not exists (select up.profile_index from user_profile up where up.user_id= @is_user and up.profile_index=1) and
PP.APPLICATION_CODE = @is_appl AND
PP.MENU_NAME=@menu_name --and
--PP.MENU_ITEM=tb1.menu_item
) as enabled
From sys_menu_item as tb1
where tb1.MENU_ITEM not in ('m_window','m_help','m_toolbar') and tb1.item_parent not in ('m_toolbar','m_window','m_help')
And tb1.item_parent= @menu_name
--Members
UNION ALL
select tb2.item_text, tb2.orden, tb2.read_order, tb2.item_parent , tb2.menu_item ,
(SELECT 'N' FROM PROFILE_PERMISSION PP
INNER JOIN sys_menu_item ON PP.MENU_ITEM=sys_menu_item.menu_item
WHERE PP.PROFILE_INDEX in (select up.profile_index from user_profile up where up.user_id= @is_user) and
not exists (select up.profile_index from user_profile up where up.user_id= @is_user and up.profile_index=1) and
PP.APPLICATION_CODE = @is_appl AND
PP.MENU_NAME=@menu_name -- and
-- PP.MENU_ITEM=tb1.menu_item
) as enabled
from sys_menu_item as tb2 , GetHierarchy
where tb2.MENU_ITEM not in ('m_window','m_help','m_toolbar') and tb2.item_parent not in ('m_toolbar','m_window','m_help')
And tb2.item_parent = GetHierarchy.menu_item and tb2.menu_name = @menu_name
)
select Space(5*(orden)) + item_text as menui, orden, read_order, item_parent , menu_item ,enabled
From GetHierarchy
END
///////////////////////////////////////////////////////////////
So far so good.
The problem is in a specific part of the sql statement (which is also part of my business logic).
the following statement has a little problem.
(SELECT 'N' FROM PROFILE_PERMISSION PP
INNER JOIN sys_menu_item ON PP.MENU_ITEM=sys_menu_item.menu_item
WHERE PP.PROFILE_INDEX in (select up.profile_index from user_profile up where up.user_id= @is_user) and
not exists (select up.profile_index from user_profile up where up.user_id= @is_user and up.profile_index=1) and
PP.APPLICATION_CODE = @is_appl AND
PP.MENU_NAME=@menu_name --and
--PP.MENU_ITEM=tb1.menu_item
) as enabled
When I'm executing, it tells me that the Subquerry is returning more than one rows. I have tried to use TOP 1 but Sqlserver 2005 doesn't allow you to do that because you are inside a recursion.
I have tried to do this
(SELECT TOP 1 'N' FROM PROFILE_PERMISSION PP
INNER JOIN sys_menu_item ON PP.MENU_ITEM=sys_menu_item.menu_item
WHERE PP.PROFILE_INDEX in (select up.profile_index from user_profile up where up.user_id= @is_user) and
not exists (select up.profile_index from user_profile up where up.user_id= @is_user and up.profile_index=1) and
PP.APPLICATION_CODE = @is_appl AND
PP.MENU_NAME=@menu_name --and
--PP.MENU_ITEM=tb1.menu_item
) as enabled
But the system prevents me from doing that.
Any ideas ? How can I return only one row (I don't care which one) ?
Can I put this Sql statement in a function and then call it inside this recursion ? Is it permitted ?
I would mostly appreciated any help you can give me.
Thank you
zkar
I am using the code below to get all the children of a particular product and it is working fine. How to get the particular product's id in the select statement. for example, i need to show 891 in a separate column for all the records returned by the query below.
DECLARE @Hierarchy TABLE (Product_Id INT, Parent_Product_Id INT)
INSERT INTO @Hierarchy VALUES (123, 234)
INSERT INTO @Hierarchy VALUES (234, 456)
INSERT INTO @Hierarchy VALUES (456, 678)
INSERT INTO @Hierarchy VALUES (678, 891)
INSERT INTO @Hierarchy VALUES (891, NULL)
[Code] .....
Hi,
I just want to know how do you called when you are accessing another pc thru \. I forgot how it is called.
Second, I like to know what [MACH] and [INST]. They don't look like directories.
\MultforestHEALTH[MACH][INST]HEALTH_WAREHOUSEDeploy_20080228p_Vitals_FACT.sql'
How can I execute or access a web page from a DTS package?
Both SQL server AND website are hosted on the same server (a Dual 2.4Gz Xeon with 2Gb RAM, RAID 5 etc)
I have 2 tables in SQL server 2000 that hold orders. These need to be posted into another table at a predefined time (ie: 4:30pm) and at the same time, access a remote address (a web service) and post certain elements of the order back.
Basically, can anyone help me out on how to execute a web page from a DTS.
I do NOT want to access a DTS from a webpage, which is all I'm finding at the moment.
Hello,
Question is, when I try to create relationships in SQL 7 without using the wizard..upon adding the tables I get an errror message that says "Coinitialization has not been called". What does this mean?
CREATE PROCEDURE sp_getT
@m1 int ,
@txn int ,
@Pan varchar(50) ,
@Act varchar(50) OUTPUT,
@Bal Decimal(19,4) OUTPUT,
@CBal Decimal(19,4) OUTPUT
AS
declare @pBal money, @pCbal money, @pAct money
SET NOCOUNT ON
IF @m1 = 200
BEGIN
IF @txn = 31
BEGIN
exec ChkBal @Pan, @pBal output, @pCbal output, @pAct out
END
END
SET @Act = @pAct
SET @Bal = cast(@pBal as Decimal(19,4))
SET @CBal = cast(@pCBal as Decimal(19,4))
return @Act
return @Bal
return @CBal
the above code returns this error message
"Server: Msg 8144, Level 16, State 2, Procedure CheckBalance, Line 0
Procedure or function ChkBal has too many arguments specified."
How do i specify all the arguments i want in the called procedure?
Hi everyone -
I'm stumped on what to cal this, there might even be
a method or pattern named for what i am trying to accomplish...
In the database, a number field is included on each table
When the DAL reads the record from the database, it is passed to
the client - work is possibly done to the record and is sent
back to the DAL for update.
A query is done against the table to retrieve the record again,
the numbers are compared - if they don't match, it is assumed the record
been modified by another user/thread/activity. An error is returned to the client stating the data has been changed.
if the numbers match, the record is updated with the number field being incremented by one.
what is this methodology called (beside crap :-) )
thanks
tony
Hello, perhaps you guys have heard this before in the past, but here iswhat I'm looking for.I have a SQL 2000 table with Social security numbers. We need tocreate a Member ID using the Member's real SSN but since we are notallowed to use the exact SSN, we need to add 1 to each number in theSSN. That way, the new SSN would be the new Member ID.For example:if the real SSN is: 340-53-7098 the MemberID would be 451-64-8109.Sounds simply enough, but I can't seem to get it straight.I need this number to be created using a query, as this query is areport's record source.Again, any help would be appreciated it.
View 9 Replies View Related
Hi
I have a drop down list which gets populated from database but I want to add the default value as
--Select----
This seems like a basic question but I have not been able to find the answer in the help files or by searching this forum.
Is a trigger called for each row updated or is it called once for all rows updated?
for example if I have:
Code Snippet
CREATE TRIGGER mytrigger
ON mytable
AFTER UPDATE
AS
BEGIN
EXEC e-mail-me inserted, N'mytrigger', getdate()
END
and I do this
Code Snippet
UPDATE mytable
SET mycolumn = N'whatever'
WHERE ID > 5 AND ID <= 10
Assuming there is a record for each nteger value of ID, than will mytrigger run 5 times (once for each row updated) or one time (with inserted containing all 5 rows)?
Hi,
When a column is evaluated against an UDF in a SELECT ... or WHERE ... It makes sense that the UDF is called for every row of the SELECT. But is it still true if the UDF is called in a subquery as below?
Code Snippet
SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus())
I've made a test and the SQL Profiler Trace shows that the UDF is called only once.
Can anyone confirm if my test is valid and most importantly that the UDF is called only once? FYI, I never use sub queries. This is to clarify a technical detail for our performance investigation.
Thank in advance for any help.
Here is the code to setup the test:
USE NorthWind
GO
CREATE TABLE dbo.UdfTest (
LineID int Identity(1,1) NOT NULL,
AnyText varchar(200) COLLATE database_default NOT NULL
)
GO
INSERT dbo.UdfTest (AnyText) VALUES ('Test1')
INSERT dbo.UdfTest (AnyText) VALUES ('Test2')
INSERT dbo.UdfTest (AnyText) VALUES ('Test3')
GO
CREATE FUNCTION dbo.F_Bogus (
)
RETURNS @tab TABLE (
LineID int NOT NULL,
AnyText varchar(100) COLLATE database_default NOT NULL)
AS
BEGIN
INSERT @tab (LineID, AnyText) VALUES (1, 'UDF1')
INSERT @tab (LineID, AnyText) VALUES (2, 'UDF2')
INSERT @tab (LineID, AnyText) VALUES (3, 'UDF3')
INSERT @tab (LineID, AnyText) VALUES (4, 'UDF4')
INSERT @tab (LineID, AnyText) VALUES (5, 'UDF4')
RETURN
END
GO
Here is the capture of SQL Profiler when executing the statement:
SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus())
SQL:BatchStarting SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543
SQLtmtStarting SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543
SPtarting SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (1, 'UDF1') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (2, 'UDF2') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (3, 'UDF3') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (4, 'UDF4') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (5, 'UDF4') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus RETURN 51 2008-05-06 17:58:31.577
SQLtmtCompleted SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543
SQL:BatchCompleted SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543
My package inserts rows into tables with triggers.
The triggers are not being called.
What might be causing this?
Hello everyone:
I have some nightly jobs that execute stored procedure to call the tables? I want to know which table are called by these stored procedures. Is it possible? Any idea will be appreciated.
Thanks
ZYT
I am encountering an issue which is effecting our production environment, none of our sql jobs are now saving any kind of job history, nor are the status of the jobs being saved.
I have run a profiler trace and it seems as if procedure : sp_sqlagent_log_jobhistory is not being called during the execution of any of our jobs
Has anyone else encountered anything similar?
Hi
In a stored procedure the following code snippet 1 checks against duplicate data being inserted. I've tested it with snippet 2 and it works as expected. However, when the procedure is called from ASP.NET the check seems ineffective. I still get the error msg. The application uses a SqlDataSource with the following parameters.
Any suggestions?
Thanks,
Bakis.
PS I want to ask a question on the ASP.NET forum .The login/pwd for this forum "get me in" to the .net forum in the sense that when I log in I see a logout link. I don't get an "ask a question" button though. Is there a separate screening for each forum?
<UpdateParameters>
<asp:Parameter Name="CatItemUID" Type="Int32" />
<asp:Parameter Name="CatName" Type="String" />
<asp:Parameter Name="Item" Type="String" />
<asp:Parameter Name="Quad" Type="Int16" />
<asp:Parameter Name="UID" Type="Int64" />
</UpdateParameters>
snippet 1 :
if (@CatItemComboExists > 0 )
BEGIN
--print @CatItemComboExists
return 0
END
snippet 2:
begin tran
declare @return_status int
EXECUTE @return_status = spUpdateCatItemRec 343, 'blah','blih', 2,3
print @return_status
rollback
error msg only if proc is called from app
Violation of UNIQUE KEY constraint 'IX_tblCatItemUID'. Cannot insert duplicate key in object 'tblCatItemUID'.
I am maintaining some C# and ASP.NET code with SQL server 2000. My code calls a stored procedure. The code is a little confusing as to the name of the SQL Server stored procedure that is calling. At this point I don't know how to trace into or debug the stored procedure. Kind of hard to do in the first place when you are not absolutely certain as to the stored proc to be called.I can take an educated guess as to which stored procedure is being called. I figure if I can deliberately make a certain stored procedure fail then this might be able to somehow give me the name of the stored proc that I am calling.So is there a way to do this. Namely make a stored procedure fail, or to return the name of the stored Proc?I would sincerely appreciate some help with this problem.
View 1 Replies View RelatedIm using a SqlDataSource control. Ive got my "selectcommand" set to the procedure name, the "selectcommandtype" set to "storedprocedure"What am i doing wrong ? Ive got a Sql 2005 trace window open and NO sql statements are coming through "ds" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="my_proc_name" SelectCommandType="StoredProcedure">
"txtF1" Name="param1" Type="String" />
"txtF2" Name="param2" Type="String" />
"" FormField="txtF3" Name="param3" Type="String" />
"" FormField="txtF4" Name="param4" Type="String" />
Hi All,I have a report ASP.NET page that allow users to run a report by clicking a buttion to call a store procedure to generate the report, however, the store procedure is taking a few minutes to return the data, thus I got the 'timeout' error message on my page. How do I extend the time on my page?Thanks
View 3 Replies View RelatedCan someone please reply w/ example syntax on how to receive calculated variables from an invoked SP. DESCRIPTION:
sp_caller invokes sp_calc_values (passing @var1, @var2) via:
exec sp_calc_values @var1, @var2
sp_calc_values receives @var1, @var2 then calculates @var3, @var4
HOW does sp_caller receive the calculated values @var3, @var4 ???
thx in advance
Hi,
Please help me to elucidate a mistery !
I have a little SP in a database:
CREATE PROCEDURE XXXTest AS
DECLARE @a varchar(50)
SELECT @a = NULL
IF @a NOT IN ('x', 'y')
BEGIN
RAISERROR ('Error',16,1)
RETURN 0
END
RETURN 1
If I execute it from SQL Server, it returns 0. (after the error, of course).
If I execute it from MS ACCess through a Pass Through Query, it returns 0.
On the same server !!!
How could it to make me that ? I have been thought the SP is executed entirely on the server !!!
Thanks in advance clearing me the mind.
Mircea.
Running sqlserver 2000
In oracle, it is called rpad and lpad for adding character to the left of
the output string or right of the output string.
Example,
I am selecting a zip_code 10200 and it truncates last 2 zeros when I
run select on the table.
If I just run select zip_code from test;
I will receive following result in oracle.
102
So, I run select rpad(zip_code,5,'0') from test;
This will add last two zeros to the the string.
Result in Oracle;
10200
How can you do this in sqlserver?
Please let me know.
Thanks,
Ranjan
Hello all. I have a stored procedure that seems to skip the execution of an entire line of code (which happens to be a call to execute another stored procedure), but ONLY if it is being used from C# (using the System.Data.SqlClient namespace... object: SqlCommand, etc).
Basic structure:
Event SP: top-most parent
-->Calls UpdateXs SP: This is the SP that will not call his child SP
----->Calls UpdateX: This is the SP that is being ignored when called from .NET (In a loop, each iteration, max iterations 10).
(1) I can call the top-most stored procedure (Event SP) with the same arguments in Query Analyzer and all SP's will execute.
(2) I can call UpdateXs SP with the same arguments that are being passed to it from Event SP in the Query Analyzer, and again, it's child sp executes (UpdateX).
(3) I can also call the last child (UpdateX) directly in Query Analyzer with the same arguments that are passed in production (from executing the top-most parent in C#), and it executes correctly.
I'm positive that at no point the last child (UpdateX) is being passed NULL values. I made debug tables and before execution of an SP from within another SP, I store all the arguments in a debug table--none are null. Also, to figure out what was wrong with the last child (UpdateX) , the first statement in inserts into another debug table, just to show that that execution has made it into the sp--when the top parent is called from C#, it doesn't insert into my table (doesn't execute).
There are statements inside Event SP that execute after the sp call to UpdateXs SP. These statement always execute. Also, there are statements inside UpdateXs SP that execute after the sp call to the last child. These statement always execute too.
I am now clueless. I had developed & debugged all sp's in Query Analyzer before trying to use it live (with the C#). It's always fine in Query Analyzer, but ALWAYS skips the last sp in production.
Is there some fundamental principle I am missing here in MS SQL stored procedures? I am only 3 levels deep in SP calls, so I didn't think that would be an issue (I have made SP's that went a LOT deeper in calls than that in the past with no issues).
Any insight much appreciated. Thanks in advance.
Hello,
I am a student and is currently busy with an SQL project. I am having trouble with creating a view to calculate and display the hours worked for each call rate..
It goes...
I have two tables: rate and consultancydetail.
The rate table consists of columns named - id, time descripiton and rate.
The consultancydetail table - invoiceID, rateID date, startTime and endTime.
My view should display the rateId column and then there should be a column created in the view for the total hours.
total hours is calculated by adding the difference between startTime and endTime and then added to each total for each rateId.
PLEASE CAN SOMEONE HELP. I am new to this and know it should be a simple thing.
cheers,
Arend
Hi,
I have to create a view that displays the average quantity used per invoice for each product. and substitute NULL values with zeros.
Please I need help and will appreciate any!
I have a MATERIALDETAIL table with columns invoiceID, productCode and Quantity.
THIS IS WHAT I HAVE SOFAR:
*************************
create view vw_ProductAverage
as
select distinct product_code
from materialdetail
go
select * from vw_productAverage
go
***************************
PLEASE help.
Hi,I have a large FoxPro table with an index that I need to be Queried from SQLServer by OLE.DB or ODBC. If I query the DBF directly a search takes 1Minute +. Is there a way I can call the data from the table and use theexisting FoxPro Index?ThanksSteve
View 1 Replies View RelatedOK, here's the scenario:
I have some libraries (DLL) that I call from a regular console application. The data access methods get the connection string from the app.config, nothing special there.
The thing is: now I need to use the libraries inside a SSIS package. I call them from a script task, and everything is fine, except for the connection string.
Is there a way that I can get the connection string from the SSIS package configuration like I would from the app.config? Maybe some alternative to ConfigurationManager.AppSettings["ConnString"] in the DTS Runtime?
Thanks in advance...
I have a task configured on the post execute event handler of a package expecting this task to be executed only once after the completion of all the other tasks in the package. But I found the task configured on the post execute event of the package getting executed as many times as the number of tasks in the package + 1 . Is there any workaround for this problem?
View 1 Replies View Related
Hi All,
I have a Stored Procedure, which has a RAISERROR statement with LOG. I am calling this SP from a Job. Whenever the RAISERROR is executed, it also fails the job.. How should this be handled? The article:
http://support.microsoft.com/kb/309802 says that this has been fixed in SP4, but I am working on SQL Server 2000 SP4, but still it persists here. Can anyone please help me resolve issue? Can this be handled in Code? Or, Is it confirmed that even SP4 has not fixed this? Or is this a known issue and we need to live with it?
Thanks a lot,
Manoj Deshpande.
This is a very weird problem. SQL 2000. A bcp calls an SP:
bcp "exec MyDB.dbo.usp_DF_NA_Analytics_OOW" queryout SomeFile.dat -T -c -t "|" -S "MySvrMyInst"
SP code:
----------------------------
CREATE PROCEDURE dbo.usp_DF_NA_Analytics_OOW AS
BEGIN
SET NOCOUNT ON
--Declare Variables
DECLARE @CURRENTDATE DATETIME
DECLARE @BEGINTIME DATETIME
declare @feedname varchar(50)
set @feedname = 'DF_NA_Analytics_OOW'
SET @CURRENTDATE = CURRENT_TIMESTAMP
-- ensure there is a row for us - create 1 if it doesn't exist
exec usp_datafeed_timestamp_init @feedname
SET @BEGINTIME = (
SELECT LastRunTime
FROM NewAccounts.dbo.DataFeed_Timestamp
WHERE TaskName = @feedname
)
select oowReason.OOWTransaction_id,
oowReason.Position,
oowReason.ReasonCode,
oowTx.UpdateDateTime
from OOWTransaction oowTx (nolock)
join OOWReason oowReason (nolock)
on oowReason.OOWTransaction_id = oowTx.OOWTransaction_id
WHERE oowTx.UpdateDateTime >= @BEGINTIME and oowTx.UpdateDateTime < @CURRENTDATE
ORDER BY oowReason.OOWTransaction_id, Position
-- update the timestamp
exec usp_UPD @feedname, @currentdate
end
------------------------------
ALTER procedure dbo.usp_UPD (@feedname varchar(50), @lastruntime datetime)
as
begin
set nocount on
if not exists (select * from dbo.datafeed_timestamp where lower(taskname) = lower(@feedname))
INSERT INTO Datafeed_Timestamp(TaskName, LastRunTime) VALUES(@feedname, @lastruntime )
else
update Datafeed_Timestamp
set LastRunTime = @lastruntime
where TaskName = @feedname
end
----------------------------------------
The above bcp fails consistently unless the "exec usp_UPD" is completely removed.
Even if I substitute it with the update stmt instead of the SP call, it still fails.
I move the usp_UPD call and move it above the select making the select as the last command in the SP -- still fails.
Removed Order by -- still fails.
The weird thing is -- several other SPs that follow the same exact format (only select query is different) - they all succeed everytime.
This above bcp fails everytime unless the usp_UPD is fully removed.
I have tried putting the result dataset into a table variable and select it in the end -- still fails. several other attempt to workaround - fails -- by fails I mean "0 rows returned" from bcp -- when the UPD is removed, it returns the correct dataset. Otherwise always returns 0 rows.
Outside bcp, if I simply execute the SP from QA, it returns the correct dataset everytime. From bcp, it just doesn't like it. It returns 0 rows everytime, but does the UPD task -- the value does get updated adter execution.
Any thoughts/ideas? This thing is driving me NUTS
Thanks,
Rajesh
When I call DeriveParameters against a function written in SQLCLR function it throws an exception. I've been working on this a little while and haven't found a fix. I understand that I could write additional code to do the same work DeriveParameters does, but it seems like this should work.
This is the exception thrown:
[InvalidOperationException: The stored procedure 'GSI.Utils.IsMatch' doesn't exist.]
The function is defined as
CREATE FUNCTION [Utils].[IsMatch](@Value [nvarchar](4000), @RegularExpression [nvarchar](4000))
RETURNS [bit] WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [RegularExpressionsHelper].[UserDefinedFunctions].[IsMatch]
The C# function is defined as:
[Microsoft.SqlServer.Server.SqlFunction(IsDeterministic=true)]
public static SqlBoolean IsMatch(SqlString Value, SqlString RegularExpression)
{
Regex rx = new Regex( RegularExpression.ToString() );
string s = Value.ToString();
return new SqlBoolean(rx.IsMatch(s));
}
This is the code I'm using to call DeriveParameters:
static void Main(string[] args)
{
using (SqlConnection conn = new SqlConnection(m_GetConnectionString()))
{
conn.Open();
SqlCommand myCommand = new SqlCommand("GSI.Utils.IsMatch", conn);
myCommand.CommandType = System.Data.CommandType.StoredProcedure;
SqlCommandBuilder.DeriveParameters(myCommand);
}
}
I found that DeriveParameters seems to call sp_procedure_params_managed and when I call it myself it returns the parameters correctly for T-SQL functions, but returns no records when I specify a SQLCLR function.
DECLARE @procedure_name sysname;
DECLARE @group_number int;
DECLARE @procedure_schema sysname;
DECLARE @parameter_name sysname;
SET @procedure_name = 'IsMatch';
SET @group_number = 1;
SET @procedure_schema = 'Utils';
SET @parameter_name = null;
DECLARE @RC int
EXECUTE @RC = [GSI].[Sys].[sp_procedure_params_managed]
@procedure_name
,@group_number
,@procedure_schema
,@parameter_name
I'm able to execute the function without issue and I'm able to use DeriveParameters against everything in the database except C# based functions (and I've tried others besides IsMatch). I'm attempting to run DeriveParameters from a console application and from ASP.NET, both running .NET 2.0.
I've experienced the same behavior in these versions:
SQL Server 2005 Enterprise Edition RTM (MSDN Image on Virtual Server)
SQL Server 2005 Enterprise Edition SP1 (MSDN Image on Virtual Server)
SQL Server 2005 Enterprise Edition SP1 + Hotfix kb918222 (MSDN Image on Virtual Server)
SQL Server 2005 Developer Edition SP1
Has anyone else seen similar behavior?
Any advice would be greatly appreciated -- Thanks
Steve
Hi,
I have implemented the code from the 'Recycling Conversations' post that Remus Resanu has posted. For some reason my sender activation procedure never gets called. I thought it was working at one point but now can not get it to work. Messages are being sent correctly from sender to receiver but the c_audit_send_queue_activation procedure never gets called.
According to my code that calls 'begin conversation timer(@dlg) timeout=30;' I would think that after 30 seconds that my activated procedure would get called with a DialogTimer message but it does not. Nor does the activation procedure on the sender get called when I manually end conversations on the receiver side.
Thanks in advance for any help.
Here is my send procedure:
Code Snippet
create procedure [dbo].[c_audit_p_send_message]
@msg nvarchar(max)
as
begin
if @msg is not null
begin
begin try
set nocount on;
declare @dlg uniqueidentifier
declare @counter int;
declare @error int;
declare @errid bigint, @dbname nvarchar(128)
set @counter = 1;
begin transaction;
while(1=1)
begin
select @dlg = dialog_id from dbo.audit_dialog with(holdlock) where audit_dialog_id_X = @@spid
if @dlg is null
begin
begin dialog conversation @dlg
from service [tcp://SFT3DEVSQL01:4022/TyMetrix360Audit/DataSender]
to service '//TyMetrix360Audit/DataWriter','7A9690F7-11A5-4ABB-ACBA-EECC1A58ACB7'
on contract [//TyMetrix360Audit/Contract] with encryption = off;
begin conversation timer(@dlg) timeout=30;
insert into dbo.audit_dialog(audit_dialog_id_X, dialog_id) values(@@spid, @dlg)
end;
send on conversation @dlg message type [//TyMetrix360Audit/Message] (@msg)
set @error = @@ERROR;
if @error = 0
begin
break;
end
set @counter = @counter + 1;
if @counter > 10
begin
raiserror(N'Failed to SEND on a converstation for more than 10 times.',16,1) with log;
insert into audit_error (error_procedure, error_line, error_number, error_message, error_severity, error_state, audited_data)
select error_procedure(), error_line(), error_number(), error_message(), error_severity(), error_state(), @msg
break;
end
delete from dbo.audit_dialog where dialog_id = @dlg;
set @dlg = null;
end
commit transaction;
end try
begin catch
insert into audit_error (error_procedure, error_line, error_number, error_message, error_severity, error_state, audited_data)
select error_procedure(), error_line(), error_number(), error_message(), error_severity(), error_state(), @msg
select @errid = scope_identity(), @dbname = db_name()
raiserror (N'Error while sending Service Broker message to TyMetrix360Audit. Error info can be found in ''%s.dbo.AUDIT_ERROR'' table with id: %I64d', 16, 1, @dbname, @errid) with log;
end catch
end
end
GO
here is the activatation procedure:
Code Snippet
create procedure [dbo].[c_audit_p_send_queue_activation]
as
begin
declare @dlg uniqueidentifier
declare @msgtype sysname
declare @msg varbinary(max)
begin transaction;
receive top(1) @dlg = conversation_handle, @msgtype = message_type_name, @msg = message_body from dbo.TyMetrix360AuditQueue
if @dlg is not null
begin
delete from audit_dialog where dialog_id = @dlg
if @msgtype = N'http://schemas.microsoft.com/SQL/ServiceBroker/DialogTimer'
begin
send on conversation @dlg
message type [//TyMetrix360Audit/Message/EndConversation] ('');
end
else if @msgtype= N'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
begin
end conversation @dlg
end
else if @msgtype = N'http://schemas.microsoft.com/SQL/ServiceBroker/Error'
begin
end conversation @dlg
declare @error int;
declare @description nvarchar(4000);
with xmlnamespaces ('http://schemas.microsoft.com/SQL/ServiceBroker/Error' as ssb)
select @error = cast(@msg as xml).value('(//ssb:Error/ssb:Code)[1]', 'int'), @description = cast(@msg as xml).value('(//ssb:Error/ssb:Description)[1]', 'nvarchar(4000)')
raiserror(N'Received error Code:%i Description:''%s''', 16, 1, @error, @description) with log;
insert into audit_error (error_procedure, error_line, error_number, error_message, error_severity, error_state, audited_data)
select error_procedure(), error_line(), error_number(), error_message(), error_severity(), error_state(), @msg
end
end
commit transaction;
end
and here is the code that creates the service broker on the sender:
Code Snippet
if exists (select * from sys.routes where name = 'TyMetrix360Route') drop route TyMetrix360Route
if exists (select * from sys.services where name = N'tcp://SFT3DEVSQL01:4022/TyMetrix360Audit/DataSender') drop service [tcp://SFT3DEVSQL01:4022/TyMetrix360Audit/DataSender]
if exists (select * from sys.service_queues where name = N'TyMetrix360AuditQueue') drop queue TyMetrix360AuditQueue
if exists (select * from sys.service_contracts where name = N'//TyMetrix360Audit/Contract') drop contract [//TyMetrix360Audit/Contract]
if exists (select * from sys.service_message_types where name = N'//TyMetrix360Audit/Message') drop message type [//TyMetrix360Audit/Message]
if exists (select * from sys.service_message_types where name = N'//TyMetrix360Audit/Message/Blob') drop message type [//TyMetrix360Audit/Message/Blob]
if exists (select * from sys.service_message_types where name = N'//TyMetrix360Audit/Message/EndConversation') drop message type [//TyMetrix360Audit/Message/EndConversation]
GO
create route TyMetrix360Route authorization dbo with
service_name='//TyMetrix360Audit/DataWriter',
broker_instance='7A9690F7-11A5-4ABB-ACBA-EECC1A58ACB7',
address='TCP://SFT3DEVSQL01:4022'
create message type [//TyMetrix360Audit/Message] validation=none;
create message type [//TyMetrix360Audit/Message/Blob] validation=none;
create message type [//TyMetrix360Audit/Message/EndConversation] validation=none;
create contract [//TyMetrix360Audit/Contract]([//TyMetrix360Audit/Message] sent by initiator, [//TyMetrix360Audit/Message/Blob] sent by initiator, [//TyMetrix360Audit/Message/EndConversation] sent by initiator);
create queue dbo.TyMetrix360AuditQueue
alter queue dbo.TyMetrix360AuditQueue with activation(status=on,max_queue_readers=1,procedure_name=[c_audit_p_send_queue_activation],execute as owner);
create service [tcp://SFT3DEVSQL01:4022/TyMetrix360Audit/DataSender] authorization dbo on queue dbo.TyMetrix360AuditQueue
grant send on service::[tcp://SFT3DEVSQL01:4022/TyMetrix360Audit/DataSender] to public
GO