I have a stored procedure that needs to return something from one of two databases:
IF @x = 1
SELECT y FROM Table_A
ELSE IF @x = 2
SELECT y FROM Table_B
Either SELECT alone will return what I want, but adding the IF/ELSE makes it stop returning anything. I tried:
IF @x = 1
RETURN SELECT y FROM Table_A
ELSE IF @x = 2
R...
Is there an in process database, like SQLite or Sql Server Compact Edition, that supports stored procedures?
...
Hello
The client that calls this code is restricted and can only deal with return codes from stored procs. So, we modified our usual contract to RETURN -1 on error and default to RETURN 0 if no error
If the code hits the inner catch block, then the RETURN code default is -4 rather then 0
Does anyone know where this comes from please?...
Currently I'm assigning a TextWriter to the Log property of my Linq to Sql data context (per request instancing) and write this to my logging when an exception is thrown while executing a stored procedure (is strongly typed mapped in the context, so not executing a custom command)
however when using ADO.NET we normally inspect the SqlCo...
How can i implement Excel COMBIN function in SQL 2005, either in a store procedure or in a function. About COMBIN function in Excel follow this Link.
Thanks.
...
Hi al,
we have 5 tables over which we should query with user search input throughout a stored procedure. We do a union all of the similar data inside a view. Because of this the view can not be materialized. We are not able to change these 5 tables drastically (like creating a 6th table that contains the similar data of the 5 tables and...
Here is my procedure...
DELIMITER $$
CREATE PROCEDURE syncSites(IN m_id INT, IN p_aux VARCHAR(2),
IN c_aux VARCHAR(2), IN price_override VARCHAR(8))
BEGIN
INSERT INTO product SELECT
m_id,
product_id,
product_name,
IF(price_override IS NULL OR price_override = '', price, price_override)...
I have a number of stored procedures structured similarly to this:
DECLARE @sql NVARCHAR(MAX)
DECLARE @mdx NVARCHAR(MAX)
CREATE table #result
(
[col1] NVARCHAR(50),
[col2] INT,
[col3] INT
)
SET @mdx = '{some dynamic MDX}'
SET @sql = 'SELECT a.* FROM OpenQuery(LinkedAnalysisServer, ''' + @mdx + ''') AS a'
INSERT INTO #result
EXE...
I'm trying to modify a stored procedure hooked into an ORM tool. I want to add a few more rows based on a loop of some distinct values in a column. Here's the current SP:
SELECT
GRP = STAT_CD,
CODE = REASN_CD
FROM dbo.STATUS_TABLE WITH (NOLOCK)
Order by STAT_CD, SRT_ORDR
For each distinct STAT_CD, I'd also like to insert a REA...
From what I can see, SubSonic 2.x stored procedure parameter data types can only be of type System.Data.DbType.
Is there a quick way to add System.Data.SqlDbType so we can use System.Data.SqlDbType.Structured to pass tables - ultimately to TVP's?
In this particular project, all data caller functions are accessed through StoredProcedu...
Hi,
I want to execute a method on VB.Net to return a date which is in the stored procedure. I tried using ExecuteScalar but it doesnt work it retruns error
'Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query'
Any help would be much appreciated please?
thank you
below is the...
Hi,
see the procedure InsertHelpQuestion2 below.
DROP PROCEDURE InsertHelpQuestion2;
CREATE PROCEDURE InsertHelpQuestion2(user_id char(50),scenerio_id char(50),component_id char(50))
BEGIN
DECLARE uu_id char(50);
SELECT BinToUUID(NewUUID()) INTO uu_id from helpquestion LIMIT 1;
SET @fields_part = 'INSERT INTO helpquestion(H...
For instance, this does not work:
DELIMITER //
CREATE PROCEDURE countRows(tbl_name VARCHAR(40))
BEGIN
SELECT COUNT(*) as ct FROM tbl_name;
END //
DELIMITER ;
CALL countRows('my_table_name');
Produces:
ERROR 1146 (42S02): Table 'test.tbl_name' doesn't exist
However, this works as expected:
SELECT COUNT(*) as ct FROM my_tab...
i have a table with column:
Registereddate orgid
2010-06-05 10:16:00 1
2010-06-05 10:10:00 2
2010-06-04 22:31:00 3
... .
. .....
.
.
.
i need to get only last weeek dates and orgid from today to last 7 days date..
...
Ok so i have a DECIMAL field called "Score". (e.g 10.00)
Now, in my SP, i want to increment/decrement the value of this field in update transactions.
So i might want to do this:
SET @NewScore = @CurrentScore + @Points
Where @Points is the value im going to increment/decrement.
Now lets say @Points = 10.00.
In a certain scenario, i...
i have stored in the database as
location
India,Tamilnadu,Chennai,Annanagar
while i bind in the grid view it ll be displaying as
'India,Tamilnadu,Chennai,Annanagar' this format.
but i need to be displayed as 'Annanagar,Chennai,Tamilnadu,India' in this format. how to perform this reverse order in query or in c#
note: this is stored ...
Hello Everyone!
I work with Crystal Report 2008 sp2, and during creation of a new report template I've encountered a problem. I created a stored procedure, which prepares and pivots needed data on the server side, and filters it using a parameter.
When I try to add this stored procedure to the report template in Crystal Editor, I recei...
Hi, when trying to create a simple procedure in mysql 5.1.47-community it fails everytime i've tried everything!
even simple things like this!
DELIMITER //
CREATE PROCEDURE two ()
begin
SELECT 1+1;
end;
//
The error is
ERROR: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server v...
Hello everyone,
I am using VSTS 2008 + C# + .Net 3.5 + ADO.Net. Here is my code and related error message. The error message says, @Param1 is not supplied, but actually it is supplied in my code. Any ideas what is wrong?
System.Data.SqlClient.SqlException:
Procedure or function 'Pr_Foo' expects
parameter '@Param1', which was not...
Similar to Insert into a temp table from a stored procedure on Sql Server 2000 from last year, but now with a strange error.
I'm using Microsoft SQL Server 2000 to dump results from one stored procedure into the temp table of another procedure. Both procedures are on the same physical server, yet I'm getting an error message as if the s...