Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

T-SQL IF Statement

$
0
0

I am working on a stored procedure for importing a xlxs document into a table within the database. Thanks to Trunker, I was able to get that part working. During debugging I realized that for some reason my parameter is not being populated as to where to grab the file from.

The stored procedure is manually triggered by the end user once they have created the file. The file name is predetermined and the user cannot change this. The file name is based off airport code of the city they are in, and the date the file was created (ex. ICT_12182013.xlsx)

The user then goes into SSRS and triggers the import by supplying the data for @payDate and @branchName

Then using an IF Statement in the stored procedure based off which branch they select and date it should set the @pathToFile.

I have almost this exact process before however it was with database names, and it worked perfectly. For some reason this one is not working.

Here is the code that is being used to attempt to obtain the @pathToFile

USE [Tempus_Fugit]
GO
/****** Object:  StoredProcedure [dbo].[loadBranchExport]    Script Date: 12/16/2013 16:50:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[loadBranchExport] 
(
	-- Add the parameters for the stored procedure
	@branchName varchar(50),
	@payDate varchar(10),
	@pathToFile varchar(260)OUTPUT
)
AS
BEGIN
   IF (@branchName = 'Wichita')
	BEGIN
	SET @pathToFile = 'C:\Export\ICT_' + @payDate + '.xlsx';
	END
END


Viewing all articles
Browse latest Browse all 4871

Trending Articles



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