Welcome to PhoneASK, where you can ask questions and receive answers from other members of the community.

sql server Print function

asked 7 days ago by NoobEditor
i need output for sql print value i am passing some values how to get that value aspx page any one help me sir

Your answer

1 Answers

answered 7 days ago by yasir
If you are trying to return a variable from your Stored Procedure, then you must declare an output variable. A sample Procedure is shown below.
You can then get the variable in your aspx page accordingly. Dont forget to handle null.
CREATE PROCEDURE [dbo].[sample]
     @input varchar,
     @output varchar OutPUT
  IF @input = 1  
    SET @output ='your message'

If you were referring to print an error message from the SQL stored Proc , then use RAISEERROR function in your SQL Procedure.
use link http://msdn.microsoft.com/en-us/library/ms178592.aspx[ ^]

You can then catch the exception in the aspx page and display it as required.

Related Questions

I am trying to print a selected value, is this possible? Example: PRINT SELECT SUM(Amount) FROM Expense
I am trying to save data to the database with Multiline textbox. and another process is to read from the database and prints to a text file. My problem is: 1) when I am trying to save the data in the
I may have a slight feeling as to what is going on, but I thought I'd ask to get confirmation, and potentially look at an alternative. As a slight background, I've written a C# application that is pro
I have the following test table in SQL Server 2005: CREATE TABLE [dbo].[TestTable] ( [ID] [int] NOT NULL, [TestField] [varchar](100) NOT NULL ) Populated with: INSERT INTO TestTable (ID, TestField) V
Assume this script: DECLARE @result TABLE(Id BIGINT); DELETE FROM [Products].[Product] OUTPUT DELETED.[Id] INTO @result WHERE [Products].[Product].[Id] = 1589; So in continues I try : 1 SELECT CAST(
I am having a query like this SELECT firstName FROM student WHERE LEN(firstName) > 5 There is a Non-Clustered Index on the 'firstName' column. It is normally advisable not to use SQL function wit
I am working on SQL Server 2008 R2. I am trying to get the sum. This is my query select SUM( case when sec.SecurityTypeID = 2 then SUM(quantity)*(sec.AnnualIncomeRate/100) when sec.SecurityTypeID = 5
I'm building a query with a GROUP BY clause that needs the ability to count records based only on a certain condition (e.g. count only records where a certain column value is equal to 1). SELECT UID,
Does SQL Server have an equivalent function to Postgres Similar to compare strings? I looking for something that will match str1 = Flat 1, 110 Bob Street str2 = 110, Bob St. Flat 1 so I can do
I create a function to execute dynamic SQL and return a value. I am getting Only functions and some extended stored procedures can be executed from within a function. as an error. The function: Crea
The following codes will print all dates throughout the current year on SQL Server 2008R2 with x (dy, yr) as ( select dy, year (dy) yr from ( select getdate () - datepart (dy, getdate ()) + 1 dy -- th
What does this built-in function do? What is the history that it is deleting?
I have a recursive scalar function that needs to update a record in another table based on the value it is returning, however UPDATE statements are not allowed in the function. How can I update the ta
I am in the middle of converting an existing SQL Server 2005 DB into a PostgreSQL 9.0 DB. Everything works fine until now. I want to translate a SQL trigger into PostgreSQL but I have a problem with t
Well, if i want to find parameter count of any stored procedure or function inside SQL SERVER, what is the correct way to do it. Your help would be appreciated. thanks.
I have an SQL database with multiple tables, and I am working on creating a searching feature. Other than having multiple queries for the different tables, is there a different way to go about said se
I have a function that takes a number as an input and converts it to a date. This number isn't any standard form of date number, so I have to manually subdivide portions of the number to various date
I have a sample data below where i want to manipulate the data and generate new database table. I want the output as below image: This is my query used to get the data: CREATE TABLE #tmp_vendorau
I'm trying to create a SQL Function that tests whether a parameter starts with a certain term or contains the term, but doesn't start with it. Basically, if the parameter starts with the term, the fun
I would like to print a SQL Server database diagram. I'm using SQL Server Management Studio, I right clicked on the diagram, and selected View Page Breaks. I wanted to have the diagram in A3 Format
I'm running a recent Linux system where all my locales are UTF-8: LANG=de_DE.UTF-8 LANGUAGE= LC_CTYPE=de_DE.UTF-8 LC_NUMERIC=de_DE.UTF-8 LC_TIME=de_DE.UTF-8 ... LC_IDENTIFICATION=de_DE.UTF-8 L
What is =1 doing here ? SELECT TOP 3 NewsId, NewsTitle, NewsContent FROM disc_News WHERE CASE WHEN DatePublish IS NOT NULL and DateExpired IS NOT NULL THEN 1 ELSE 0 END = 1
I have been struggling to find an answer or develop a solution. I am trying to figure out how to make code that makes code in Clojure. For my first feat, I want a function that will print to stdout th
We have a C++ program such as: int& Instance() { static int test; return test; } int main( int argc, char ** argv ) { int& test = Instance(); printf(%d\n,test); return 0; } Now I'm trying t
when I write code in Java, I use the debugger embedded in Eclipse. When visualizing an object in this context, the debugger automatically calls the toString() function, feature that I find very conven
My businesses application supports only reporting with selected data from SQL server.In one business process I have very complicated stored procedure which using others stored procs and it was designe
I've created a simple database using Oracle SQL (iSQL plus). How can I print the table structure and its contents?
Please help me to write a select query using to pivot my table as below My table structure And required result structure StoryLineID PlotID StoryLine Question 1 1 01 question 1 1 1 02 question 2
Hi i am writing a SQL query for a report which will give the amounts of leads coming in for the day since 8am. The report is set to go out every our so for example the 8am report will show leads which
What I want to do is count the number of rows returned by a subquery, essentially the following: select pp.prop_id, COUNT((select employee_id from employee e where e.ao1_hours > 0)) from proposal_p
I have two stored procedures, I call one stored procedure from another stored procedure and in both two stored procedures I use transactions. Below is the stored procedures, CREATE PROCEDURE [dbo].[s
ALTER PROCEDURE [dbo].[usp_Payroll_ELSurrender_Submit] ( @FinYearID INT =0, @MonthID INT =0, @EmpID INT =0, @Result INT OUTPUT ) AS BEGIN DECLARE @TotalEL INT=0 DECLARE @SurrenderEL INT=0 DECLARE @Bal
I want to use SQL Server to send email and found two possible way from the internet: Using AOSMTP.Mail Create PROCEDURE [dbo].[RC_SendEmail] @ServerAddr varchar(80), @FromAddr varchar(80), @Recipient
I created a SSL certificate using OpenSSL for my Microsoft WebServer 2003, IIS 6.0. I am able to install and use it on the client and the server side as well. Now I want to use it for my SQL Server ex
SQL Server Management Studio is not connecting with the server name in client machine, but it is working fine with server IP address.
Make Model Stock Receivable Deliverable ISUZU DMAX20 10 50 10 ISUZU DMAX10 10 20 10 Suzuki SWIFT 20 20 10 I need count of make grouped by make, count of model group by make, along with the Make,Model
In my table I got a column whose value is whether 0 or 1. If that column is 0 I output the value as 'no'; if 1 I should output as 'yes' for all rows. How can I do this only using SQL statement. Thanks
I've recently started programming asp.net with C# (using VS2008) and I wrote my first web application that connects to a database. First version worked ok but now there are some problems once I modify
If we PIVOT any table and UNPIVOT that table do we get our original table?
Table: CREATE TABLE Table1 ( col1 INT, col2 nvarchar(10), col3 INT, col4 INT ); INSERT INTO Table1 (col1, col2, col3, col4) VALUES (1, 'welcome', 3, 4); My table have different data type , col2 is nv
I am trying to create an indexed view in SQL Server and I was wondering If I needed to index the view columns. I am asking this because the view is composed of a tables that already have the columns i
I have this table in MSSQL: ID OP1 OP2 OP3 330 0 0 1 331 1 0 0 332 3 2 0 OP's are options. There can go from 1 to 9, 0 means that question was not answer. How can i sum in a column called Answered
Am having issues with escaping parts of strings in SQL. On example is: SELECT TOP 10000 * FROM experience WHERE name IS 'AT&T' Which is saying incorrect syntax near Incorrect syntax near 'AT'. Se
I have two tables: Employees(EmployeeID, EmployeeName, EmployeeStatus, BasicSalary) and EmployeePayroll (PayrollID, EmployeeID, VoucherNo, BasicSalary, SalaryMonth) I want to make a for each loop for
I have a table with values ID BarID FName LName ColA ColB ColC 1 22 Jon Carr 0 2 1 2 23 Don Brown 1 3 2 3 23 Don Brown 2 1 2 4 24 A B 0 2 1 5 24 A B 2 3 1 6 24 A B 1 2 3 Table name is Temp I want to
I have a C# application that saves pictures in a SQL Server database. SQL Server keeps pictures in a column of type varbinary(max). And the app converts byte[] to show the picture on my screen. What
How to select value from a table if it value is not null,and select a default value if not?.I.E: select coalesce(username,'its null') from tb_user where int_id_user = 0 I try to run this query but it
I have two columns, both int's, Wins and Losses. I have a calculated column WinPercentage as a decimal(14,3), I want this to be: WinPercentage = (Wins + Losses) / Wins What's the syntax for that?
I am using the SQL Server and I am stuck with the condition where I need to run 1st AND clause or 2nd AND clause based on the if condition. Please see the below query, I tried to explain my requiremen
Why do these queries return different values? The first returns a result set as expected, but the second (which as far as I can tell is exactly the same) does not. Any thoughts? 1: declare @c varchar(