Results To String Array For Reference Within CLR Proc
Jun 13, 2006
I keep running into a problem with the debugger freezing up. I'm trying to pull results from a query into an array (not more than 10 rows)
cmd.ExecuteReader();
while (rdr.Read() == true) {
letter = rdr[0].ToString();
i += 1;
}
if I comment out the "letter = rdr[0].ToString();" portion of code, the project runs fine. With that code there, I can not step into the proc from the SQL test script. No errors are raised. VS just freezes.
View 1 Replies
ADVERTISEMENT
Jun 25, 2007
I have a stored procedure that has a paramter that accepts a string of values. At the user interface, I use a StringBuilder to concatenate the values (2,4,34,35,etc.) I would send these value to the stored procedure. The problem is that the stored procedure doesn't allow it to be query with the parameter because the Fieldname, "Officer_UID" is an integer data type, which can't be query against parameter string type.
What would I need to do to convert it to an Integer array?
@OfficerIDs as varchar(200)
Select Officer_UID From Officers Where Officer_UID in (@OfficerIDs)
Thanks
View 5 Replies
View Related
Oct 13, 2000
In my front end, I have a procedure in which the operator selects multiple tickets. I have in mind to create a stored procedure which accepts its input parameter and plugs it into an IN() clause in an Update statement, something along these lines:
Update TicketInventory Set SalesID = 12345 Where TicketInventoryID IN( myInputParam );
Can I pass an array of Integers into a stored proc and have it work like this? Alternatively, I could pass a comma-delimited string containing the Integers. Could I plug that into the IN()? Or is there is yet another way to accomplish this?
TIA,
Arthur
View 1 Replies
View Related
Mar 9, 2006
Can you pass an array into a stored proc or do we have to use indiviual parameters.
If we can, any code exmaple woudl be great.
Cheers
Chris
View 4 Replies
View Related
Jul 20, 2005
I have ...CREATE PROC InvoiceDeleteExample2(@InvoiceList1 VARCHAR(255),@InvoiceList2 VARCHAR(255) = '',...@InvoiceListN VARCHAR(255) = '')AS....GOI would like....CREATE PROC InvoiceDeleteExample2(SELECT * FROM table;)AS....GOI hope help... thx
View 1 Replies
View Related
May 14, 2008
Hi All,
I have a stored proc which is executing successfully...but the results of that stored proc are displaying in the Messages Tab instaed of results Tab. And in the Results Tab the results shows as 0..So, Any clue friends..it is very urgent..I am trying to call this stored proc in my Report in SSRS as well but the stored proc is not displaying there also...Please help me ASAP..
Thanks
dotnetdev1
View 4 Replies
View Related
Jul 28, 2015
I have a string variable and following data.
Declare @ServiceID varchar(200)
set @ServiceID='change chock','change starter','wiring for lights','servicing'
when I assign values in @ServiceID in the above manner then it shows error. How to get string array in @ServiceID variable so that i can go ahead.
View 8 Replies
View Related
Apr 9, 2008
Hi I'am practically new in C#, so I want to ask you guys some question.Let say I have this query:"Select EmployeeID, EmpName from PI_Employee"How can I retrieve the result from EmployeeID column and EmpName column and put it into collections of array, so I can call the array and use it again in another function. Can I possibly do that in C# ? if so, how ? please help me guys, I'm on the edge of nervous wreck in here so I could use a little help, any kinds of help. Thanks. Best Regards.
View 9 Replies
View Related
Jul 22, 2004
How would I go about storing (1 column) database results in a Array?
And then how would I go about extracting the elements from the Array?
View 4 Replies
View Related
Jan 25, 2008
Hello All,
I have about 10 different insert into statements which I would like to include into a loop of some sort. Here is what I am trying to accomplish.
SET @aryTableNames = 'thisTable','thatTable','anotherTable'
DO
SELECT * INTO [Server].[dbo].[@aryTableNames]
FROM OPENQUERY(mysqlDB, 'SELECT * FROM `@aryTableNames`')
LOOP
View 5 Replies
View Related
Jun 14, 2006
Hello, I have a question on sql stored procedures.I have such a procedure, which returnes me rows with ID-s.Then in my asp.net page I make from that Id-s a string likeSELECT * FROM [eai.Documents] WHERE CategoryId=11 OR CategoryId=16 OR CategoryId=18.
My question is: Can I do the same in my stored procedure? Here is it:set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[eai.GetSubCategoriesById]
(
@Id int
)
AS
declare @path varchar(100);
SELECT @path=Path FROM [eai.FileCategories] WHERE Id = @Id;
SELECT Id, ParentCategoryId, Name, NumActiveAds FROM [eai.FileCategories]
WHERE Path LIKE @Path + '%'
ORDER BY Path
Thank youArtashes
View 2 Replies
View Related
Oct 17, 1999
Greetings,
Facing a strange problem, but obviously not expected earlier on, I am trying to execute a stored procedure via ADO which refrences a linked server table and I get an error specifying
"
OLEDB provider SQLOLEDB does not contain table "<DatabaseName>"."<owner>"."<tableName>"
"
Has any one else encountered this problem before ?
regards
Govind
View 1 Replies
View Related
Apr 18, 2008
SqlDataAdapter da = new SqlDataAdapter(sql, "Data Source=xxxx;Initial Catalog=xxxx;Integrated Security=True"); I want to use my ConnectionString variable but I can't figure out how to put it in there without the compiler throwing an error.: ConnectionString="<%$ ConnectionStrings:UMBPRMConnectionString %>
View 1 Replies
View Related
Jul 13, 2006
hey, guys
I got a strange question. :)
In SQL Server,
declare @Item8 as varchar(100)
declare @str as varchar(100)
set @str = '@Item8'
Is there any way I can reference @str to @Item8 ?
Thanks
View 1 Replies
View Related
Feb 20, 2008
Folks,
I have an issue in producing output for the following query in MDX Query builder avaialable in BIDS. the error message I get is:
The query cannot be prepared: The query must have at least one axis. The first axis of the query should not have multiple hierarchies, nor should it reference any dimension other than the Measures dimension..
Parameter name: mdx (MDXQueryGenerator)
Code Snippet
WITH MEMBER [Measures].[Annualized Vs Target] AS
'[Measures].[Revenue]-[Measures].[Target Revenue]'
SELECT
NON EMPTY {
([Measures].[Balance],[Year].[Year - Year].&[2006]) ,
([Measures].[Balance], [Year].[Year - Year].&[2007]),
([Measures].[Revenue], [Year].[Year - Year].&[2006]),
([Measures].[Target Revenue], [Year].[Year - Year].&[2007]),
([Measures].[Revenue], [Year].[Year - Year].&[2007]),
([Measures].[Annualized Vs Target], [Year].[Year - Year].&[2007])
}
ON COLUMNS ,
NON EMPTY { ([Client - Coverage Region].[Region Name].[Region Name].ALLMEMBERS *
[Client].[Client Name].[Client Name].ALLMEMBERS)} ON ROWS
FROM [MIS POC FINAL]
Do Anybody has a solution for this? I require the output to be in the following format :
Region_Name(RegDim) Client_Name(ClientDim) Balance_2006 Balance_2007 Revenue_2007 TargetRevenue_2007
USA A 20000 30000000 40000000 5000000000
B 60000 70000000 80000000 9000000000
Note: We can execute the above query in SSMS-MDX Query window without any issues.
Many Thanks in Advance for any assistance.
Subhash Subramanyam, Suraj Magdum
View 6 Replies
View Related
Apr 19, 2006
I have this stored proc:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[usp_CrimRecTest]
-- Add the parameters for the stored procedure here
@caseID [nvarchar]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT dbo.tblCASENOMASTER.CASENO, dbo.tblCASEMAST.LASTNAME, dbo.tblCASEMAST.FRSTNAME
FROM dbo.tblCASENOMASTER LEFT OUTER JOIN
dbo.tblCASEMAST ON dbo.tblCASENOMASTER.CASENO = dbo.tblCASEMAST.CASENO
WHERE (dbo.tblCASENOMASTER.CASENO = @caseID)
END
When I run this with an EXEC statement, the result pane shows no results but the message pane says it completed successfully and one row is affected. I know my input data is good. I also get nothing when I call this sproc from a VB front end. Any ideas?
Thanks.
View 4 Replies
View Related
Jun 10, 2008
Hi guys. I'm trying to compare the results from various stored procedures. Various stored procedures in our database got redone (refactored), and I want to see if they still pull back the same data.
Are there any programs out there that do this? Compare result sets from stored procedures? Any help is appreciated. Thanks!
View 1 Replies
View Related
Jul 23, 2005
Try hard to become familiar with T-SQL.Can anybodey tell me the best way to deal with set's provided by astored procedure. Til yesterday I thougt trapping set in temp tableusing INSERT EXEC is a way out of this, but then I struggeled withnested INSERT EXEC's.What are all the system proc's good for if the results cannot beevaluated? The approach of modular programming is to have code doingsimilar things in one place.If I try to make use of sp_helprolemember to get login names for moreroles, pack the logins in one table and return the result set in a SP,the procedure which calls that is unable to evaluate the set.On the other hand I read the advice, not to access system tablesdirectly.Is there a way out?
View 9 Replies
View Related
Jan 12, 2007
Hello,
I have tried to use a DaraReader Source to execute a SQL Server 2000 proc, and send the results to an Excel Destination.
The proc is named spv_CDGetFuelManDuplicates. Within the proc, temporary tables are created and dropped. When I attempt to set 'Exec dbo.spv_CDGetFuelManDuplicates' for the SqlCommand property of the DataReader, I get an error message indicating that my temporary tables are invalid objects.
The DaraReader is using an ADO.NET Connection Manager.
Should I be using an Execute SQL Task instead?
Thank you for your help, the proc code is below.
cdun2
********************************
alter PROCEDURE dbo.spv_CDGetFuelManDuplicates
AS
--Isolate Accounts and Contact Info per the View criteria
SELECT
RTRIM(Acctcode) AS AcctCode,
RTRIM(CompanyName)AS CompanyName,
MMS#, RTRIM(Phone) AS Phone
INTO #CorrectAcctCodes
FROM dbo.DailyAccountsDownload
WHERE
(AcctCode BETWEEN 'IQ001' AND 'IQ999') OR
(AcctCode BETWEEN 'QI001' AND 'QI999') AND (AcctCode NOT IN ('QI125', 'QI601', 'QI603', 'QI613', 'QI623', 'QI653', 'QI697')) OR
(AcctCode BETWEEN 'DQ001' AND 'DQ999') AND (AcctCode NOT IN ('DQ011')) OR
(AcctCode BETWEEN 'FQ002' AND 'FQ999') AND (AcctCode <> 'FQ011')
--Isolate duplicate phone numbers
--per the view criteria
SELECT
RTRIM(Phone)AS Phone, COUNT(*) AS RecordCount
INTO
#DupPhoneNumbers
FROM
dbo.DailyAccountsDownload
WHERE
(AcctCode BETWEEN 'IQ001' AND 'IQ999') OR
(AcctCode BETWEEN 'QI001' AND 'QI999') AND (AcctCode NOT IN ('QI125', 'QI601', 'QI603', 'QI613', 'QI623', 'QI653', 'QI697')) OR
(AcctCode BETWEEN 'DQ001' AND 'DQ999') AND (AcctCode NOT IN ('DQ011')) OR
(AcctCode BETWEEN 'FQ002' AND 'FQ999') AND (AcctCode <> 'FQ011')
GROUP BY
RTRIM(Phone)
HAVING
(COUNT(*)>1)
--Isolate duplicate Company Names
--per the View criteria
SELECT
RTRIM(CompanyName)AS CompanyName,
COUNT(*) AS RecordCount
INTO
#DupCompanyName
FROM
dbo.DailyAccountsDownload
WHERE
(AcctCode BETWEEN 'IQ001' AND 'IQ999') OR
(AcctCode BETWEEN 'QI001' AND 'QI999') AND (AcctCode NOT IN ('QI125', 'QI601', 'QI603', 'QI613', 'QI623', 'QI653', 'QI697')) OR
(AcctCode BETWEEN 'DQ001' AND 'DQ999') AND (AcctCode NOT IN ('DQ011')) OR
(AcctCode BETWEEN 'FQ002' AND 'FQ999') AND (AcctCode <> 'FQ011')
GROUP BY
RTRIM(CompanyName)
HAVING
(COUNT(*)>1)
--Result with duplicate company or phone numbers
SELECT
Acctcode, CompanyName, MMS#, Phone
FROM
#CorrectAcctCodes
WHERE
Phone IN (SELECT Phone FROM #DupPhoneNumbers)
OR
CompanyName IN (SELECT CompanyName FROM #DupCompanyName)
ORDER BY
Phone, companyname
--Drop the temp tables
DROP TABLE #CorrectAcctCodes
DROP TABLE #DupCompanyName
DROP TABLE #DupPhoneNumbers
View 2 Replies
View Related
Jul 21, 2015
I would like to create a function that will replace a string using a reference table
I have a table : reference
ID String ReplaceWith
1 ≈ &
2 < <
3 > >
If I pass a string into a function, function needs to replace a string with replace with string column in reference table
For example, if I pass a string : car $ap; fjld
The function should return car & fjld
How can i create a function like this so that i can call it in Stored procedure....
View 12 Replies
View Related
Aug 9, 2000
I have a search stored proc which fails to return results when called by more than one user.
I have put selects in the various SPs to trace results and if I call from 3 query windows (executnig each as quickly as I can work the mouse) I get the following:
1st query returns the trace values (including correct count of temp table recs) but no result set
2nd query erturns nothing just "The command(s) completed successfully."
3rd query returns full results.
This seems to be consistent.
We are running SQL Server 7 SP1.
Just upgrading to SP2 to see if that helps.
The main SP calls other SPs to build result sets.
These use quite a few temp tables passed between SPs, parse CSV lists, join different other tables, create a SQL string to exec to do the search and get record IDs to return (no cursors).
The result set is built by a called SP using the temp table with IDs to return.
Anyone know of any problems or can suggest anything to try?
View 3 Replies
View Related
Jul 20, 2005
Hi,I am using data from multiple databases and/or queries. It would greatlysimplify and speed things up if I could use CONTAINS in processing theresults. However, "CONTAINS" requires the data to be indexed. Due to theamount of processing, I think it would be faster even if I had to re-indexevery time.For example, I would like to do something like this (simplified toillustrate the desired functionality... This should show all of the wordsfrom one table that are not contained in their current or inflectional formswithin another table):SELECT W1.ContentFROM(SELECT Word AS ContentFROM MyTable) W1LEFT OUTER JOIN(SELECT Phrase AS ContentFROM MyOtherTable) W2ON W2.Content CONTAINS(INFLECTIONAL, W1.Content)WHERE W2.Content IS NULLCan the results of a procedure be indexed? If not, can I drop the resultsinto a new table and trigger an automatic index of it, pausing the procedureuntil the indexing is done?Or, it there another way?Thanks!
View 2 Replies
View Related
Nov 18, 2006
Hi,I have written a stored procedure which includes a DATEPART command, i.e.DATEPART(weekday, <date>)The result when ran from SQL Query Analyser is as expected . i.e. Sundayreturns 1, Monday 2, etcWhen the same proc is called from within the Access 2000 project Sundayis returned as 7, Saturday as 6 instead of 1 and 7 respectively.Basically the same stored proc returns different data depending on fromwhere it has been called.This is causing some issues obviously as the resulting tables andreports are showing incorrect data when presented in Access 2000.Has anyone else experienced this before or have any idea what may cause it.Regards,PB
View 1 Replies
View Related
Jan 25, 2007
All,
I am using Reporting Services 2005. One of my reports is getting the following error when I try to export to Excel. It will export to .CSV though.
"Destination array was not long enough. Check destIndex and length, and the array's lower bounds."
Any suggestions would be greatly appreciated. Please copy me at machelle.a.chandler@intel.com.
Machelle
View 10 Replies
View Related
Jan 21, 2005
Hi Guys,
I have an nVarChar field named "Event" (I know - I didn't name it !) with variable length values such as *ALARM* or *RESTORE*
They always start or end with a * and I want to trim them off before returning the data to my app.
I've got rid of the first one with...
LTRIM(STUFF(Event, 1, 1, ''))
Any tips on how to get rid of both of them in one go ?
Thanks in advance.
Steve.
View 2 Replies
View Related
Feb 27, 2008
This should be an easy enough answer to find if I just knew what to search on!
I am building a query within my stored procedure based on what parameters are passed in. For example, suppose I have a table with first name and last name. I can call the sp with either first name or last name or both, so I build a query accordingly that says:
select * from tblNames where FirstName = 'Hannah'
or
select * from tblNames where LastName = 'Montana'
or
select * from tblNames where FirstName = 'Hannah' and LastName='Montana'
My problem is putting the single quotes around the variable value.
SELECT @whereClause = @whereClause + ' AND tblNames.LastName=' @LastName-with-singlequotes-around-it
Thanks
View 3 Replies
View Related
Nov 8, 2007
Hi,
I have a stored proc which accepts a varchar(255) as a parameter and when I call the proc using a concatenised string I get an error i.e.
-- Proc
CREATE PROCEDURE #proc_param_test
@p_param1 varchar(40) = NULL
, @p_param2 varchar(40) = NULL
AS
BEGIN
SELECT @p_param1, @p_param2
END
EXEC #proc_param_test 'test', 'test 2'
returns
---------------------------------------- ----------------------------------------
test test 2
but EXEC #proc_param_test 'test', 'test 2' + ' - the rest'
gives a Incorrect syntax near '+'. error
The solution must be a real doddle but it's a 'mare to find anywhere.
Cheers,
John
View 4 Replies
View Related
Jun 16, 2006
I need to write a storedproc that receives the name of a table (as a string) and inside the stored proc uses select count(*) from <tablename>. The problem is the passed in tablename is a string so it can't be used in the select statement. Any ideas how I can do what I want?
TIA,
barkingdog
View 1 Replies
View Related
Oct 29, 2007
I have a fairly elaborate query that returns a string value something like this:
,,,6,7,6,7,,,,,,,,6,,,,,6,7,6,,,,,,,,,6,,,,,6,7,6,7,,,,,,,,6,,
basically its a series of numeric values seperated by commas.
What I want to do now is count the '6's ini the string and return a numeric value, i.e. the above example would = 9 and if i do the same for 7's it would return a 5
any idea on how to do this?
View 14 Replies
View Related
Jul 30, 2007
Hello,
I have a number of multi-select parameters which I would like to send to a stored procedure within the dataset for use in the stored procedure's IN() statement which in turn is used to filter on or out particular rowsets.
I considered using a hidden string parameter set = " ' " + join(parameter.value, ',') + " ' " so that the hidden parameter would then contain a comma delimiated string of the values selected, which would then be sent on to the stored proc and used in the WHERE clause of one of the queries internal to the stored proc.
But before I start dedicating time to do this I wanted to inquire if anyone here with far more expertise could think of a faster or less system heavy method of creating a single string of comma delimited parameter selections?
Thanks.
View 3 Replies
View Related
Jul 20, 2005
I need to append text to the end of my sql query results.For instance, my query returns a list of user names infirstname.lastname. I need to add @yahoo.com to each record. So theend result should be Join Bytes!. What should byselect statement look like?Any help?
View 2 Replies
View Related
Jul 21, 2015
CREATE TABLE Test
(
EDate Datetime,
Code varchar(255),
Cdate int,
Price int
);
[Code] ....
Now I have to pass multiple param values to it. I was trying this but didnt get any success
exec
[SP_test]'LOC','LOP'
View 10 Replies
View Related
Jul 21, 2015
I want to extract a number within a column results, that is the number between the first two commas
Example:
select path from tablea
results:
1158285,1158286,1158287,1158288,1158289
1158288,1158289,1158290,1158291,1158292
....
How to extract the second number(between the first two commas) from the above results?
The output should be
1158286
1158289
View 2 Replies
View Related