I have next block in the end of each my stored procedure for SQL Server 2008
BEGIN TRY
BEGIN TRAN
-- my code
COMMIT
END TRY
BEGIN CATCH
IF (@@trancount > 0)
BEGIN
ROLLBACK
DECLARE @message NVARCHAR(MAX)
DECLARE @state INT
SELECT @message = ERROR_MESSAGE(), @state = ERROR_STATE()
RAISERROR (@message, 11, @state)
END
END CATCH
Is it possible to switch CATCH-block to
BEGIN CATCH
ROLLBACK
DECLARE @message NVARCHAR(MAX)
DECLARE @state INT
SELECT @message = ERROR_MESSAGE(), @state = ERROR_STATE()
RAISERROR (@message, 11, @state)
END CATCH
or just
BEGIN CATCH
ROLLBACK
END CATCH
?
I have a job which has a stored procedure that copies data from one server to another.But problem is that there are two servers,in one i've to copy data in batch of 50 and other in the batch of 10.So,i need to check ip addresses in that case
I am trying to access a stored procedure and I'm getting an error that says:
Procedure or function 'getbug' expects parameter '@bugID', which was not supplied.
This is my code to call the procedure.
SqlCommand cmd = new SqlCommand("getbug", cn);
cmd.Parameters.Add(new SqlParameter("bugID", bugID));
bugID is set as 1089 (and is type int)
I can't figure out why this won't work.
I have a stored procedure which is returning me about 50 columns. I want to write a query, where I will be able to select a particular column from the list of column returned by the SP.
I tried writing select RSA_ID from exec(uspRisksEditSelect '1') But Its throwing me an error.
I think we need to write some dynamic sql for it. But I am new to it.
Anyone have an idea about how to use sp_helptext to view a stored procedure on a linked server? basically something like this. I don't have the credentials to that linked server to look at it.
EXEC sp_HelpText '[ServerName].[DatabaseName].dbo.storedProcName'
thanks ahead.
I'm trying to pass a table name into my mysql stored procedure to use this sproc to select off of different tables but it's not working...
this is what I"m trying:
CREATE PROCEDURE `usp_SelectFromTables`(
IN TableName varchar(100)
)
BEGIN
SELECT * FROM @TableName;
END
I've also tried it w/o the @ sign and that just tells me that TableName doesn't exist...which I know :)
I have a gridview setup that gets its data from a SQL database stored procedure. This procedure will return one of several different tables. The gridview complains if the table is different than the one previously displayed. How do I work around this?
Hello,
What do you think , does the Stored Procedure always return 1 ?
I am concerned about the if exists(..)
BEGIN
DECLARE @IsUserExisting bit
SET NOCOUNT ON
IF Exists
(
Select null FROM G_User WHERE
SamAccountName = @SamAccountName
AND NetBIOSDomainName = @NetBIOSDomainName
)
BEGIN
SET @IsUserExisting = 1
END
ELSE
BEGIN
SET @IsUserExisting = 0
END
Select @IsUserExisting
END
I'm creating a paging class and need to pass in two parameters to my MySQL stored procedure for the LIMIT clause.
I'm passing them in as INTs and trying something like this
SELECT *
FROM
`MyTable`
LIMIT
MyFirstParamInt, MySecondParamInt
it gives me an error when I try and save the sproc though. Is there a way to do this that I'm just missing? Or am I going to have to EVAL the whole query and EXECUTE it?
hi friends,
I am trying to insert data into particular table through pl/sql stored procedure,my requirement is while inserting i should generate PRIMARY KEY values for particular column and also i should return that PRIMARY KEY value to output and one more thing is that for another column i should validate my string such that it should contain only characters not integers.
please help me in writing code for the above requirement
Thanks and regards
thulasi policherla
instead of returning my output paremeter value in my stored procedure to my label it returns the default value i set my output parameter to.
why cant i put my output parameter into my text label
Dim reader As SqlDataReader
cmd.Parameters.AddWithValue("@tour", "2365")
cmd.Parameters.Add("@tourname", SqlDbType.VarChar)
cmd.Parameters("@tourname").Direction = ParameterDirection.Output
cmd.CommandText = "test"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = conn
conn.Open()
reader = cmd.ExecuteReader()
Dim myTable As DataTable = New DataTable()
myTable.Load(reader)
DropDownList1.DataSource = myTable
DropDownList1.DataTextField = "ddate7"
DropDownList1.DataBind()
Label1.Text = cmd.Parameters("@tourname").ToString
conn.Close()
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#
Hi, i'm pretty new to Javascript and PHP so please bear with me if i'm asking some really dumbed down questions.
Ok, say i need to use values stored in a PHP $_GET or $_SESSION, is it advisable to just do something like
var something = PHP echo $_SESSION or $_GET
Hello.
I faced the following problem: there's a user who has to execute a stored porcedure (spTest). In spTest's body sp_trace_generateevent is called. sp_trace_generateevent requires alter trace permissions and I don't want user to have it. So I would like user to be able to execute spTest. How can I do that?
Thank you for your help.
Hello,
I have a dataaccesslayer which uses Enterprice libraries.
Now I was wondering what is better?
Using stored procedures to create my sql or writing sql strings within the dataaccess classes?
Cheers,
M
i'm new to programs so bear with me
For example, Firefox.. I go to the C/program files/mozilla/firefox folder ..but I don't see the images/buttons they used for the default theme of the program
Also, photoshop and other programs: how are the buttons, images, and other media stored (not in a folder from what I see)?
same thing when I made a simple program in visual c++, i don't see where the icon is located at?
thanksvery much
Total records in table are 10.
Select count(ID) from table1 where col1 = 1 (Result is 8)
Select count(ID) from table1 where col2 = 1 (Result is 2)
So its a same table but count is based on different condition. How am i gonna get two results (counts) using one select statement?
Also Performance is a big concern here.
PS: I am using Stored procedure...
I have been attempting to implement the Entity framework into my project and unfortunately it seems like mapping an XML result set from SQL is not something that is supported. I also have issues with returning multiple result sets, though I understand that the EFExtensions was created to try to mitigate that issue.
Is there a way to take a FOR XML EXPLICIT result from a SQL Stored Procedure and map it using the Entity Framework?
I wonder if scala.dbc supports stored procedures?
The mysql jdbc backend I'm using supports it, bonus points for a code illustration to show how it works.
Hi
I am creating a stored procedure to which i want to pass as variable a comma delimited list of Ids
I want to use the Ids into a select statement
something like
Create Procedure up_TEST
@Ids VARCHAR(MAX)
AS
SELECT * FROM ATable a
WHERE a.Id IN(@Ids)
Obviously i get the error that @Ids is a varchar and not an INT but how can i convert the comma delimited list
I am using SQL Server 2008
Thanks
Hi All
SaveNotes *saveNotes = [[SaveNotes alloc]initWithTitleString:title descrString:descr];
[titleDescrObjects addObject:saveNotes];
[saveNotes release];
from the above code i have saved title,descr to a class SaveNotes , and then i have stored that object in my NSMutableArray - titleDescrObjects,
Its working fine,
i need to get particular objects "descr" alone,
how to get the descr from objectAtIndex:i
i am trying
for (int i=0; i<[titleDescrObjects count]; i++)
{
NSLog(@"\n ((%@))\n",[titleDescrObjects objectAtIndex:i].descr);
}
Thanks in advance,