Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

How do I enclose a variable in single quotes in SP

$
0
0

Hi there

Here is what I would like to execute

SELECT * FROM sale
WHERE id =1 AND caldate >='10/1/2015' AND caldate <='10/31/2015'

and I don't know how to write this in SP

CREATE PROCEDURE [dbo].[sale]
	@id int,
	@ftdate datetime,
	@ldate datetime
AS
BEGIN
	SELECT *  FROM sale
	WHERE id = @id AND caldate >= "'" + @fdate + "'" + AND caldate <= "'" + @ldate + "'"
END
GO

Is this a correct way to enclose a variable in single quotes?

Thanks for your time.

Joe



Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>