Tag: stored-procedures

How do I execute a MS SQL Server stored procedure in java/jsp, returning table data?

I am having difficulty executing a MS SQL Server stored procedure from Java/jsp. I wish to return a table set of data; the last line of the stored procedure is a regular select statement from a table. (From this point, executing a stored procedure is a cinch in PHP.) I took a look at these […]

Using function as a parameter when executing a stored procedure?

This question already has an answer here: Incorrect syntax near ')' calling storedproc with GETDATE 2 answers

How to pass a null variable to a SQL Stored Procedure from C#.net code

Im calling a SQL stored procedure from a piece of C#.net code: SqlHelper.ExecuteDataset(sqlConnection, CommandType.StoredProcedure, STORED_PROC_NAME, sqlParameters); where the sqlParameters variable is defined as: SqlParameter[] sqlParameters = new SqlParameter[SQL_NUMBER_PARAMETERS]; Log.Logger.Debug(string.Format(“Running proc: {0} “, STORED_PROC_NAME)); SqlParameters[0] = new SqlParameter(“fieldID”, SqlDbType.BigInt ); SqlParameters[0].Value = fieldID; SqlParameters[0].Direction = ParameterDirection.Input; I need to now pass in another two parameters to […]

Conditional SQL ORDER BY ASC/DESC for alpha columns

Writing a stored procedure in MS SQL Server 2008 R2, I want to avoid using DSQL… I would like the sort method (ASC or DESC) to be conditional. Now, with a numeric column I would simply use a case statement and negate the value to emulate ASC or DESC… That is: … ORDER BY CASE […]

How to search sql server database for string?

I know it’s possible, but don’t know how. I need to search Microsoft SQL database for all mentions of specific string. For example: I would like to search all tables, views, functions, stored procedures, … for string “tblEmployes”. (Not data within the tables) One of the reasons I need this, I would like to remove […]

SQL Server stored procedure return code oddity

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 […]

T-SQL Dynamic SQL and Temp Tables

It looks like #temptables created using dynamic SQL via the EXECUTE string method have a different scope and can’t be referenced by “fixed” SQLs in the same stored procedure. However, I can reference a temp table created by a dynamic SQL statement in a subsequence dynamic SQL but it seems that a stored procedure does […]

Syntax check all stored procedures?

i want to ensure that all stored procedures are still syntactically valid. (This can happen if someone renames/deletes a table/column). Right now my solution to check the syntax of all stored procedures is to go into Enterprise Manager, select the first stored procedure in the list, and use the procedure: Enter Alt+C Escape Escape Down […]

Populate Dataset With Table Names From Stored Procedure

I have a stored procedure that returns multiple tables. It populates my dataset correctly but it names my tables [Table,Table1,Table2,…]. Is there something I can add in the database layer (to my stored procedure) that will name the tables properly?

Returning multiple tables from a stored procedure

In my winform application I have the following scenario: I want to get multiple tables on a single event. Returning all tables as dataset in single server cycle, or getting one table at time and using separate server cycle for each table which one is better? What are the advantages one over another?

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.