December 12, 2005 at 4:56 am
Hello friends..
Can somebody clear my idea..
See I write sql staement like
DECLARE @intBrID int
DECLARE @dtSearchDate datetime
DECLARE @intStatus int
DECLARE @strSql varchar(4000)
set @intBrID = 12
BEGIN
SET @strSql = N'Select vchrNominationCode,intEnquiryID,intSrNo,dtAcklDate,vchrEnquiryCode,dtEnquiryDate,intTripNo,vchrCustName,vchrVehicleCarriageType,vchrLocation,intNominated,vchrRegnNo,dtLoadingDate,intSettled FROM('
SET @strSql = N'' + @strSql + N' SELECT TranEnquiryAcklDetail.intEnquiryID,TranEnquiryAcklDetail.intSrNo,TrEq.dtEnquiryDate AS dtAcklDate,TrEq.vchrEnquiryCode + ' + '''/''' + ' + CAST(TranEnquiryAcklDetail.intSrNo AS varchar(3)) AS vchrEnquiryCode,CAST(DAY(TrEq.dtEnquiryDate) AS varchar(2)) + ' + '''-''' + ' + CAST(DATENAME(month,TrEq.dtEnquiryDate) AS varchar(3)) + ' + '''-''' + ' + CAST(YEAR(TrEq.dtEnquiryDate) AS varchar(4)) AS dtEnquiryDate,vchrCompany AS vchrNominationCode,TranEnquiryAcklDetail.intTripNo,mstCustomer.vchrCustName,mstVehicleCarriageType.vchrVehicleCarriageType,mstLocation_1.vchrLocation + ' + ''' - ''' + ' + mstLocation_2.vchrLocation AS.............................
like that.....
Here i declare @strSql as varchar(4000)
exec (@strSql 
can i use here
Execute sp_executesql @strSql
when basically i use nvarchar(4000) and varchar(4000)
plz let me know...
Regards,
Papillon
December 12, 2005 at 5:53 am
Basically NVARCHAR is a double-byte version of VARCHAR.
Some procedures demand that an NVARCHAR is passed and sp_executesql is one of them
If you run
sp_executesql 'SELECT * from sales'
you get an error because SQL thinks this is an 8 bit ASCII string.
If you run
sp_executesql N'SELECT * from sales'
it works because the preceding 'N' casts the string as a double-byte value.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply