Sqlserver notes

how to assign return value of stored procedure to a new variable
CREATE PROCEDURE dbo.sp_Name
@In INT,
@Out VARCHAR(100) OUTPUT

AS
BEGIN
SELECT @Out = ‘Test’
END
GO

If you are unable to change the stored procedure, another solution would be to define a temporary table, and insert the results into that

DECLARE @Output VARCHAR(100)

CREATE TABLE #tmpTable
(
OutputValue VARCHAR(100)
)
INSERT INTO #tmpTable (OutputValue)
EXEC dbo.sp_name 9999, 99989999, ‘A’, ‘S’, null

SELECT
@Output = OutputValue
FROM
#tmpTable

DROP TABLE #tmpTable

—-

sql server find string in another string

DECLARE @document varchar(64);

SELECT @document = ‘Reflectors are vital safety’ +
‘ components of your bicycle.’;
SELECT CHARINDEX(‘bicycle’, @document);

Result : 48

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: