Left(@Variable, 50) on MS SQL insert SP

garethtnash
garethtnash used Ask the Experts™
on
Hello Experts,

Is this possible and or the best way of doing it? Mainly the 'LEFT(@Referer,50) ' of the insert statement?

If not is there a way of doing this on the page -

Session Refere = Left(server.variables(http_refere) 50  (ASP VBScript)

Thanks

Many thanks


ALTER PROCEDURE [dbo].[JobboardJobSeekerProfileApplicationInsert]
@ProfileID int,
@AdvertID int,
@Referer nvarchar(1000)
AS
Insert into 
dbo.JBApplication(
JBAPAdvertID, 
JBAPEmployeeID, 
JBAPClientID, 
JBAPSiteID, 
JBAPName, 
JBAPCoveringLetter, 
JBAPCV, 
JBAPCandidateID,
JBAPEmail,
JBAPRefer)
Select 
A.JBAID, 
A.JBAEmployeeID, 
A.JBAClientID, 
A.JBASiteID, 
(C.JBCAFirstName + ' ' + C.JBACAName) AS Name, 
P.JBCPProfileLetter, P.JBCPCV, C.JBACAID, C.JBACAUsername, LEFT(@Referer,50) 
From dbo.JBAdvert A
INNER JOIN  dbo.JBCProfile P ON A.JBASiteID = P.JBCPSiteID
Inner Join dbo.JBACandidate C on C.JBACAID = P.JBCPCandidateID
Where JBCPID = @ProfileID
AND A.JBAID = @AdvertID
GO

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Consultant
Top Expert 2009
Commented:
>Is this possible
You can use the LEFT () statement, can you provide more info about your question

Author

Commented:
Hi Aneeshattingal I just want to check that I can Left(a variable,50) on an insert.
So forinstance in the statement I create a variable called @Referer, which is Request.ServerVariables ("HTTP_REFERER")
I dont want to stall the whole URL as this could impact the database, I merely want to know which site refered the user, so on the insert I'm trying to minimise the insert to 50 characters....
Although it would be better for me, if I could limit this on the ASP Page?? maybe?
 
Does that help at all?
 
Thank you
sure you can. I don't see why not

You can do this on either asp side or sql side

Author

Commented:
Thank you done it on the server side ASP Page -

<%
if (cStr(Session("REFERER")) = "") then
  Session("REFERER") = (LEFT(Request.ServerVariables("HTTP_REFERER"),50))
end if
%>

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial