Single Quotes And Parameters

Dec 17, 2003

Help please! I have a problem with passing quotes in a parameter. I am using asp.net (vb) passing a parameter to a stored procedure.





Here is an example of the parameter I am passing from the asp page.





strIndexFilesFound = " 'file1.pdf', 'file2.pdf' "


.......Parameters("@IndexFilesFound").Value = strIndexFilesFound





And the Procedure parts





...


@IndexFilesFound char(100) = ''


....


WHERE IndexFile IN(@IndexFilesFound)








The result should be that the where query receives the data like this.


WHERE IndexFile IN ('file1.pdf', 'file2.pdf')





The number of files passed is unknown for any given query.





Much Thanks!

View 1 Replies


ADVERTISEMENT

Single Quotes And Double Quotes

Jan 3, 2002

I had a procdure in SQL 7.0 in which I am using both single quote and double quotes for string values. This proceudreused to work fine in SQL 7.0 but when I upgraded SQL 7.0 to SQL 2000, this proceudre stopped working. When I changed the double quotes to single quotes, it worked fine.

Any Idea why ??

Thanks

Manish

View 2 Replies View Related

Triple Single Quotes

Dec 3, 2003

I was having some issues with converting this @BeginDate(which is passed in as a datetime) correctly and someone suggested the syntax below. It enloses it in triple single quotes. That seemed to work, but it also seems to work with single quotes too. Can someone explain the use of triple single quotes in stored procedures?


''' + CAST(@BeginDate as Varchar(30)) + '''

View 1 Replies View Related

Single Quote Becoming Two Quotes

Jan 18, 2001

I have 2 SQL 6.5 databases on separate servers. Server A replicates a text field into a table on server B.

On server A the field contains text similar to THIS IS FRED'S HOUSE. After replication to Server B it looks like THIS IS FRED''S HOUSE. The distribution database also has it as THIS IS FRED''S HOUSE. Using ODBC trace I cannot see the value being passed in the text field as it is displayed as a question mark e.g. ?.

How do I fix the problem ?
Thanks

View 1 Replies View Related

Escaping Single Quotes

Jun 16, 2004

Hi,

I need to have an varchar value with single quotes. For eg: the below code throws compilation error.

Declare @val VARCHAR(20)
SELECT @val = ''+name+''
print @val

Error: Invalid column 'name'


I want to print name enclosed with single quotes. Please guide me.

Regards,
Sam

View 1 Replies View Related

Trouble With Single Quotes

May 3, 2004

Hello Everyone!

I am having a problem with updating a password within a table. Below is the old and new password that needs to be updated.
Old2"3("-"3#@(%P="''_DD@D*
New :"I+)#]*1#E,%R-''7^,TEA$X&^O_-68DIK,@

Below is the query that I am trying to run. I believe my problem is becuase of the Single Quotes found within both the old and new password.

I have tried to escape the single quotes, @local_variable, CHAR(39) and other ways of playing with the string. I cannot seem to find a solution.

If you were to ignore the update statement, the SELECT statement would return no results even though the PRINT statement displays the required data.
This is what baffles me and why I cannot run the UPDATE statement, becuase of course, nothing would be updated since no results were returned.

Can anyone offer their assistance?

Thank you in advance.

__________________________________________________ _______________

DECLARE
@OLD_PASSWORD VARCHAR(50),
@NEW_PASSWORD VARCHAR(50)

-- 2"3("-"3#@(%P="''_DD@D* ///// The old password.

SET @OLD_PASSWORD = '2"3("-"3#@(%P="' + CHAR(39) + CHAR(39) + '_DD@D*'

-- :"I+)#]*1#E,%R-''7^,TEA$X&^O_-68DIK,@ ///// The new password.

SET @NEW_PASSWORD = ':"I+)#]*1#E,%R-' + CHAR(39) + CHAR(39) + '7^,TEA$X&^O_-68DIK,@'

PRINT @OLD_PASSWORD
PRINT @NEW_PASSWORD

SELECT *
FROM Credentials
WHERE
Is_Active = 1 AND
[Password] = @OLD_PASSWORD

/* Attempt to update the password table. */
UPDATE Credentials
SET [Password] = @NEW_PASSWORD
WHERE [ID] IN
(SELECT [ID]
FROM Credentials
WHERE
Is_Active = 1 AND
[Password] = @OLD_PASSWORD )

View 2 Replies View Related

Escape Single Quotes

Dec 4, 2007

Hi,

I want to pass a query to SQL Server 2005 through the table adapter query.

Some of the variables with have single quotes e.g. He's

I know with PHP/MySQL Addslashes() is used.

What is the alternative for C#?

Thanks.

View 2 Replies View Related

How To INSERT Text That Contains Single Quotes?

Nov 7, 2006

When users enter text into a textbox, to be INSERTed into my table, SQL Server throws an error if their text contains a single quote.
For example, if they enter "It's great!" then it causes this error:Error: Incorrect syntax near 's'. Unclosed quotation mark after the character string ''.
How can I allow text with single quotes to be inserted into the table?
 
Here's my code: 
string strInsert = "INSERT INTO [Comments] ([GameID], [UserID], [Comment]) VALUES (@GameID, @UserID, @Comment)";
SqlConnection myConnection = new SqlConnection(<<myconnectionstuff>>);SqlCommand myCommand = new SqlCommand(strInsert, myConnection);
myCommand.Parameters.Add( "@GameID", Request.QueryString["GameID"] );myCommand.Parameters.Add( "@UserID", (string)Session["UserID"] );myCommand.Parameters.Add( "@Comment", ThisUserCommentTextBox.Text );
try {myCommand.Connection.Open();myCommand.ExecuteNonQuery();}
catch (SqlException ex) {ErrorLabel.Text = "Error: " + ex.Message;}
finally {myCommand.Connection.Close();}
 
 

View 10 Replies View Related

How To INSERT A String That Contains Single-quotes?

Dec 28, 2006

My code results in SQL statements like the following one - and it gives an error because of the extra single-quotes in 'it's great': 
UPDATE Comments SET Comment='it's great' WHERE UserID='joe' AND GameID='503'
Here's the error I get when I try this code in SQL Server: 
Msg 102, Level 15, State 1, Line 1Incorrect syntax near 's'.Msg 105, Level 15, State 1, Line 1Unclosed quotation mark after the character string ''.
I need to know how I can insert a string such as 'it's great' - how do I deal with the extra quotes issue? is there a way to ecape it like this 'it/'s great' ? This doesn't seem to work.
Here's the code that generates the SQL. I'm using a FCKeditor box instead of a TextBox, but I got the same error when I was using the TextBox:
string strUpdate = "UPDATE Comments SET Comment='";strUpdate = strUpdate + FCKeditor1.Value;//strUpdate = strUpdate + ThisUserCommentTextBox.Text;strUpdate = strUpdate + "' WHERE UserID='";strUpdate = strUpdate + (string)Session["UserID"];strUpdate = strUpdate + "'";strUpdate = strUpdate + " AND GameID='";strUpdate = strUpdate + Request.QueryString["GameID"];strUpdate = strUpdate + "'";
SqlConnection myConnection = new SqlConnection(...);SqlCommand myCommand = new SqlCommand(strUpdate, myConnection);
try{myCommand.Connection.Open();myCommand.ExecuteNonQuery();}catch (SqlException ex){ErrorLabel.Text = "Error: " + ex.Message;
}finally{myCommand.Connection.Close();}
 
I'm using SQL Server 2005 and ASP.NET 2.0 
Much thanks

View 5 Replies View Related

How To Use LIKE In Stored Procedure With Single Quotes

Jan 23, 2007

I'm trying to build a dynamic sql statement in a stored procedurre and can't get the like statement to work. My problem is with the single quote.  for example LIKE '%@searchvalue%'.  This works fine: select * from view_searchprinters where serialnumber like '%012%' But I can't figure out how to create this in a stored procedure.  What syntax should I use for the line in bold?SET NOCOUNT ON;DECLARE @sn varchar(50)SET @sn = N'012'DECLARE @sql nvarchar(4000)SELECT @sql = 'select top 10 * from view_searchprinters'    + ' WHERE 1 = 1 'SELECT @sql = @sql + ' 'IF @sn IS NOT NULL   SELECT @sql = @sql + 'and serialnumber LIKE ''' + '%' + '@sn' + '%' + ''' 'EXEC sp_executesql @sql, N'@sn varchar(50)', @sn  

View 8 Replies View Related

Insert Problem With Single Quotes

May 24, 2006

I have a problem with inserting a string with single quotes. For instance,
string testme = "we don't have anything";
insert into tableone (buff) values ("'" + testme + "'");
I get an error with the word "don't" with single quote. But if I delete the single quote "dont" then it inserts okay. Is is a bug in sql 2005? Please help. Thanks.
blumonde

View 2 Replies View Related

Insertion With Single Quotes Problem

May 24, 2006

I have a problem with inserting a string with single quotes. For instance,
string testme = "we don't have anything";
insert into tableone (buff) values ("'" + testme + "'");
I get an error with the word "don't" with single quote. But if I delete the single quote "dont" then it is okay. Is is a bug in sql 2005? Please help. Thanks.
blumonde

View 5 Replies View Related

Concatination Problem With Single Quotes

Jun 26, 2001

hello,

i have a problem to concatinte sigle quotes to variable value

declared a variable name @a as varchar(30)

set @a='keerthi'
now i would like to concatinate sigle quotes in front of string and back of string.

set @a= "'" + @a + "'"
here it is giving error.

plese give me some solution

thanks
ravi

View 5 Replies View Related

Insert A String With Single Quotes

Aug 28, 1998

Hi,

How to insert a string value with quotes in it in SQL Server?

This is not working:

insert table_name values(`abc`d`)

I tried to put escape in front of `, still failed.

Thanks in advance.

-Jenny Wang

View 2 Replies View Related

Using Single Quotes In EXEC Statement

Mar 27, 2001

View 1 Replies View Related

Dynamic SQL - Single Quotes In String

Dec 14, 2005

I'm constructing a SQL string that needs single quotes in the WHERE clause. How do I encapsulate them in a string variable. I looked into ESCAPE and SET QUOTED_IDENTIFIER, but i don't really see any examples using string Concatenation. I'm trying to filter out the zls (0 length strings)

This doesn't work (all single quotes):

@sqlString = ' SELECT * FROM myTbl '
@sqlString = @sqlString + 'WHERE fld1 <>'' '

Thanks,
Carl

View 5 Replies View Related

Query With Single Quotes Using OPENROWSET

Jul 23, 2005

I'm trying to pass through a SQL statement to an Oracle database usingOPENROWSET. My problem is that I'm not sure of the exact syntax I needto use when the SQL statement itself contains single quotes.Unfortunately, OPENROWSET doesn't allow me to use parameters so I can'tget around the problem by assigning the SQL statement to a parameter oftype varchar or nvarchar as inSELECT *FROM OPENROWSET('MSDAORA','myconnection';'myusername';' mypassword',@chvSQL)I tried doubling the single quotes as inSELECT *FROM OPENROWSET('MSDAORA','myconnection';'myusername';' mypassword','SELECT *FROM AWHERE DateCol > To_Date(''2002-12-01'', ''yyyy-mm-dd'')')But that didn't work. Is there a way out of this?Thanks,Bill E.Hollywood, FL

View 1 Replies View Related

I'm Baffled By The Single Quotes With STMT

Jul 20, 2005

Hi,Don't worry about the vars, they are defined,the following line give me an err of "Incorrect syntax near '.'."Goal: to rename nonstardard column name.EXEC sp_rename '+@tbuffer+'.['+@cbuffer+']','+Replace(+@cbuffer+','%[^A-Za-z0-9_#$@]%','')','COLUMN';Thanks.

View 6 Replies View Related

How To Enclose Variable In Single Quotes In SP

Oct 9, 2015

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,

[Code] ...

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

View 6 Replies View Related

Single - Double Quotes Problem In Query

May 19, 2008

Hi All, I am facing quotes problem. Without using the quotes
my query is running fine, but I need to use IIF condition so for that I
need quotes adjustment. I didn't figured it out how to adjust them, try
several techniques but no success. I am using dotnetnuke. {IIF,"[frmradio,form]=text"," SELECT Docs.FileName, Dept_LegalLaw.MediaID, Dept_LegalLaw.ID, Dept_LegalLaw.LevelID, Dept_LegalLaw.LawID, Dept_LegalLaw.LawDate, Dept_LegalLaw.Agreement, Dept_LegalLaw.Name, Dept_LegalLaw.NameSearch, Dept_LegalLawType.LawType, Dept_LegalLaw.LawNo, Dept_LegalMinistries.RegID, Dept_LegalLaw.IssueNo, Dept_LegalLaw.Attachment, Dept_LegalLaw.Amendment, Dept_LegalLaw.Scanned, Dept_LegalLaw.Html, Dept_LegalMinistries.Description FROM OPENQUERY(LEGALDBSERVER, 'SELECT Filename FROM SCOPE() WHERE Contains('" @FilterAnyWrd ")' ) AS Docs INNER JOIN Dept_LegalLaw ON Docs.FileName = Dept_LegalLaw.FileName INNER JOIN Dept_LegalMinistries ON Dept_LegalLaw.RegID = Dept_LegalMinistries.RegID INNER JOIN Dept_LegalLawType ON Dept_LegalLaw.LawID = Dept_LegalLawType.LawID ", " "} {IIF,"'[frmradio,form]'='title'"," SELECT MediaID, Dept_LegalLaw.ID, Dept_LegalLaw.LevelID, Dept_LegalLaw.LawID, LawDate, Agreement, Name, NameSearch, Dept_LegalLawType.LawType, LawNo, Dept_LegalMinistries.RegID, IssueNo, Attachment, Amendment, Scanned, Html, Dept_LegalMinistries.Description, Dept_LegalLaw.FileName FROM Dept_LegalLaw LEFT JOIN Dept_LegalMinistries ON Dept_LegalLaw.RegID COLLATE DATABASE_DEFAULT = Dept_LegalMinistries.RegID COLLATE DATABASE_DEFAULT INNER JOIN Dept_LegalLawType ON Dept_LegalLaw.LawID COLLATE DATABASE_DEFAULT = Dept_LegalLawType.LawID COLLATE DATABASE_DEFAULT WHERE @FilterLawNo AND @FilterLawID AND @FilterRegID AND @FilterIssueNo AND @FilterFromDate AND @FilterToDate AND @FilterNtContNew AND @FilterAgreement AND @FilterAllWrdNew AND @FilterExWrdNew AND @FilterAnyWrdNew ORDER BY [SORTTAG] ", " "} Thanks for any help

View 2 Replies View Related

Inserting Text Containing Single Quotes Into A Table

Mar 14, 2002

Update TableName
Set Field2 = 'This text contains '' single quote's'
Where Field1 = 10

How is this usually done?

Thanks

View 1 Replies View Related

Single Quotes Inside Stings In SQL Inserts In VB ADO

May 18, 1999

cmd1.commandtext = "Insert table_bug(name, address, phone, comment) Values('" & name & "','" & address & "','" & phone & "'," & ",'" comment & "')"

from VB ADO where comment contains single qoutes like 'don't'.

Insert fails. Please help!

View 1 Replies View Related

HOw Can Use Single Quotes With Variable In Select Caluse

Aug 18, 2007

define @strName as varchar(50) NULL

set @strName=(SELECT strname from Table)

SELECT '+ @strName +' from Table

It does not work

View 1 Replies View Related

Newbie Q: Inserting Strings With Single Or Double Quotes

Sep 15, 1999

Hi: Got a newbie question that's been giving me fits! Basically I'm replicating what's going on here on this board...creating a "posting" interface that takes the "message" and inserts it into a table using an ADODB connection (using INSERT INTO table name,tablecells and VALUES)

However, if someone types in a single or double quote in the body of the message, I get an error similar to this:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 's'.

/test.asp, line 29


I think I understand why it's happening (SQL is interpreting the quote mark as a string-end), but what am I supposed to do to get around it?

View 1 Replies View Related

Including Single Quotes In Dynamic Pivot Tables?

Feb 26, 2015

I have this pivot table (I only post the static version as the problem only regards the single quotes)

SELECT * from(
select DATEPART(year,DeliverydatePackingSlip) as Year,
CASE WHEN DiffPromiseDateFirst < 0 Then '1 - too early'
WHEN DiffPromiseDateFirst = 0 Then '2 - on time'
ELSE '3 - too late' END as Delivery
from iq4bisprocess.FactOTDCustomer
WHERE OTD_Exclusion = 0)a
PIVOT ( COUNT(Year)
For Year

in ([2012],[2013],[2014],[2015])) as pvtNow, packing everything in a string parameter I always stumble over the single quotes. I tried to replace them with CHAR(39), I tried to define a parameter for each occurrence, but always get a syntax error. What am I doing wrong?declare @sql nvarchar(max)

declare @title1 nvarchar(20)
declare @title2 nvarchar(20)
declare @title3 nvarchar(20)
set @title1 = '1 - too early'
set @title2 = '2 - on time'
set @title3 = '3 - too late'

[Code] .....

exec sp_executesql @sqlThis would throw:Msg 102, Level 15, State 1, Line 3 Incorrect syntax near 'early'.

View 2 Replies View Related

How To Import Flat Files With Single And Double Quotes Imbedded In Them?

Aug 8, 2006

I've got a flat file data source, that is to large to edit with most Windows apps on my server that contains both single and double quote characters that I need to load in a varchar column.

So I attempted to do it with a Replace in data transformation, but I can't get SSIS to allow me to use a variable or pair of single or double quotes within the replace.

If I don't replace the single quote characters with a pair then the records containing these characters all end up in my failed records output file.

Here are 5 example property legal descriptions from my FLAT FILE data source:

COM 441'6" N OF SW/C OF NW4 OF SEC 22-29-20 ELY1340' N200' CROSSING THE CNTR OF TR AT 100 WLY1240' S200' TO POB CONTAINING 6 3/10 ACRE MOL

N 50' OF S 330' OF W 122' OF E 735' OF SW4 OF NE4 OF SEC 28/28/18 A/K/A LOT

271 BLK "M" OF$PB 14/36-T

LOT 9 BLK "BA" OF$PB 39/1

OVERCODED POST LTS 17 21-42 47-55 & 69 PB 27/110 "ALL" SECS 16-21, 28 29/31/19 & "ALL"

N 100' OF S 815' OF TR "H" OF PB 28/58 LESS W 15' FOR ESMT ESMT DESC AS W 15' OF S 815' OF TR "H" OF PB 28/58

View 2 Replies View Related

Form Field Returns Name With Double Quotes Instead Of Single Quote During Update Process.

Oct 3, 2007

I've a weird problem in my application. In of the pages, while trying to update the text box "Name", when I enter Linda's test, it gets saved as Linda''s test. I'm not sure if this is a problem due to SQL server. When I look at the stored procedure, I don't anything different. Also, when I update the table directly in SQL Server, the result is displayed in single quote. But if I update the field thro' the application, the returned name is with double quotes instead of single quote.  Has any of you faced problems like this? What am I missing? What do I need to do to get the name saved the way I entered (with single quotes) instead of double quotes?

View 1 Replies View Related

Difference Between Single Value And Mutli Value Parameters

Oct 5, 2007



Can any one tell me the difference between single value parameter and multi value parameter ? Also please explaing with some examples( not only with technical words)..

Thanks

View 6 Replies View Related

Passing Multiple Values To A Single Parameters

Dec 28, 2007

I have a SQL query that goes like this
"select * from Product where ProductID in (1,2,3)"
How can i create a stored procedure where a single input parameter can take multiple values?
Can anyone help me with this?

View 4 Replies View Related

How To Perform SELECT Query With Multiple Parameters In A Single Field In A Table

Sep 13, 2006

i just can't find a way to perform this Select Query in my ASP.Net page. I just want to find out the sales for a certain period[startDate - endDate] for each Region that will be selected in the checkbox. Table Sales Fields:       SalesID | RegionID | Date | Amount   This is how the interface looks like.Thank You.

View 1 Replies View Related

Results Produce A Single Record Based Off Of Parameters. Want To Change It So It Returns Multiple Records.

Dec 20, 2007

I have a query that will return one record as its results if you provide two variables: @login and @record_date. This works great if you only want one result. However, now what I want to do is not provide those variables and get the result set back for each login and record_date combination. The hitch is that there are several other variables that are built off of the two that are supplied. Here is the query:

DECLARE @login char(20), /*This sets the rep for the query.*/
@record_date datetime, /*This is the date that we want to run this for.*/
@RWPY decimal(18,2), /*This is the required wins per year.*/
@OCPW decimal(18,2), /*This is the opportunities closed per week.*/
@OACW decimal(18,2), /*This is opportunities advanced to close per week.*/
@TOC decimal(18,2), /*This is the total number of opportunities in close.*/
@OANW decimal(18,2), /*This is opportunities advanced to negotiate per week.*/
@TON decimal(18,2), /*This is the total number of opportunities in negotiate.*/
@OADW decimal(18,2), /*This is the opportunities advanced to demonstrate per week*/
@TOD decimal(18,2), /*This is the total number of opportunities in demonstrate.*/
@OAIW decimal(18,2), /*This is the opportunities advanced to interview per week.*/
@TOI decimal(18,2), /*This is the total number of opportunities in interview.*/
@OCW decimal(18,2), /*This is the opportunities created per week.*/
@TOA decimal(18,2) /*This is the total number of opportunities in approach.*/

SET @login = 'GREP'
SET @record_date = '12/18/2007'
SET @RWPY = (SELECT ((SELECT annual_quota FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)/(SELECT target_deal FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)))
SET @OCPW = (SELECT @RWPY/weeks FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)
SET @OACW = (SELECT @OCPW/cls_perc_adv FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)
SET @TOC = (SELECT @OACW*(cls_time/7) FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)
SET @OANW = (SELECT @OACW/neg_perc_adv FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)
SET @TON = (SELECT @OANW*(neg_time/7) FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)
SET @OADW = (SELECT @OANW/dem_perc_adv FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)
SET @TOD = (SELECT @OADW*(dem_time/7) FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)
SET @OAIW = (SELECT @OADW/int_perc_adv FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)
SET @TOI = (SELECT @OAIW*(int_time/7) FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)
SET @OCW = (SELECT @OAIW/app_perc_adv FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)
SET @TOA = (SELECT @OCW*(app_time/7) FROM #pipelinehist WHERE loginname = @login AND record_date = @record_date)

SELECT loginname,
CAST(@TOA AS decimal(18,1)) AS [Opps in Approach],
app_time AS [Approach Average Time],
app_perc_adv AS [Approach Perc Adv],
CAST(@TOI AS decimal(18,1)) AS [Opps in Interview],
int_time AS [Interview Average Time],
int_perc_adv AS [Interview Perc Adv],
CAST(@TOD AS decimal(18,1)) AS [Opps in Demonstrate],
dem_time AS [Demonstrate Average Time],
dem_perc_adv AS [Demonstrate Perc Adv],
CAST(@TON AS decimal(18,1)) AS [Opps in Negotiate],
neg_time AS [Negotiate Average Time],
neg_perc_adv AS [Negotiate Perc Adv],
CAST(@TOC AS decimal(18,1)) AS [Opps In Close],
cls_time AS [Close Average Time],
cls_perc_adv AS [Close Perc Adv]
FROM #pipelinehist
WHERE loginname = @login AND record_date = @record_date

Here is some sample data to use with this. With this sample data what I want to get back is a total of 30 records in the result set each with its data specific to the login and record_date of that returned record.

CREATE TABLE #pipelinehist (
glusftboid int IDENTITY(1,1) NOT NULL,
record_date datetime NOT NULL,
loginname char(20) NOT NULL,
app_new float NOT NULL,
app_time float NOT NULL,
app_perc_adv float NOT NULL,
int_time float NOT NULL,
int_perc_adv float NOT NULL,
dem_time float NOT NULL,
dem_perc_adv float NOT NULL,
neg_time float NOT NULL,
neg_perc_adv float NOT NULL,
cls_time float NOT NULL,
cls_perc_adv float NOT NULL,
target_deal money NOT NULL,
annual_quota money NOT NULL,
weeks int NOT NULL
) ON [PRIMARY]

INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'AREP', 56.8, 26.9, 0.57, 29.5, 0.47, 20, 0.67, 80.7, 0.53, 2.1, 0.97, 2194.93, 575000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'BREP', 33.2, 0.5, 0.9, 7.7, 0.77, 8, 0.77, 9.2, 0.6, 7.7, 0.64, 971.1, 330000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'CREP', 210.2, 0.3, 0.87, 6.6, 0.5, 13.7, 0.4, 16.3, 0.43, 1.5, 0.91, 461.25, 330000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'DREP', 47.6, 5, 0.53, 33.3, 0.6, 57.5, 0.53, 50, 0.7, 1.5, 1, 2045.7, 575000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'EREP', 75.3, 110.9, 0.47, 36, 0.5, 17.4, 0.87, 20.3, 0.6, 7.2, 0.83, 2021.74, 775000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'FREP', 17.2, 23.3, 0.73, 6.8, 0.8, 6.3, 0.93, 29.7, 0.67, 15.5, 0.83, 2218.95, 575000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'GREP', 105.4, 67, 0.2, 32.9, 0.43, 18.5, 0.67, 8.9, 0.77, 3.5, 0.93, 1838.91, 400000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'HREP', 116.4, 118.5, 0.33, 30.9, 0.77, 46.3, 0.77, 46.3, 0.6, 0.9, 0.97, 1735.13, 1150000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'IREP', 143.3, 9, 0.77, 96, 0.17, 21.6, 0.77, 39.9, 0.43, 0.9, 0.93, 1385.43, 400000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'JREP', 179.4, 66.7, 0.7, 67.6, 0.1, 41.4, 0.6, 20.2, 0.8, 14, 0.7, 1563.76, 330000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'KREP', 107.6, 38.2, 0.23, 47.5, 0.47, 21.3, 0.77, 9.6, 0.73, 2.1, 0.83, 2120, 575000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'LREP', 18.6, 8.3, 0.87, 23.2, 0.57, 2.6, 0.87, 12.2, 0.67, 1, 1, 1229.02, 330000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'MREP', 4, 46.2, 0.6, 26.7, 0.57, 8.1, 0.87, 1.7, 0.9, 1.4, 1, 1091.22, 350000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'NREP', 54, 21.6, 0.57, 1.7, 0.77, 11, 0.8, 7.4, 0.9, 49, 0.47, 3240.68, 1300000, 50)
INSERT into #pipelinehist VALUES ('12/17/2007 0:00', 'OREP', 37.6, 24.4, 0.57, 50.1, 0.43, 6.7, 0.87, 15.6, 0.73, 0.9, 0.97, 1163.48, 330000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'AREP', 57.2, 32.5, 0.6, 29.5, 0.47, 20, 0.67, 85.6, 0.5, 2.1, 0.97, 2194.93, 575000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'BREP', 33.9, 0.5, 0.93, 7.8, 0.73, 8.3, 0.77, 9.2, 0.6, 7.7, 0.64, 971.1, 330000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'CREP', 152.1, 0, 0.87, 4.3, 0.67, 9.7, 0.47, 15.7, 0.47, 1.8, 0.85, 396.43, 330000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'DREP', 80.5, 9.8, 0.5, 40.7, 0.57, 68.3, 0.43, 64.2, 0.57, 1.5, 1, 2045.7, 575000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'EREP', 61, 92.1, 0.5, 31, 0.53, 16.9, 0.83, 17.7, 0.6, 7.3, 0.83, 2318.04, 775000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'FREP', 19.4, 21.1, 0.7, 5.3, 0.77, 2.2, 0.93, 33.3, 0.7, 9.7, 0.87, 1937.17, 575000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'GREP', 81.7, 40.5, 0.3, 33, 0.37, 18.5, 0.67, 8.9, 0.77, 3.5, 0.93, 1838.91, 400000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'HREP', 128.6, 115.7, 0.3, 30.9, 0.77, 46.3, 0.77, 48.8, 0.6, 0.9, 0.97, 1728.29, 1150000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'IREP', 100.9, 3.4, 0.77, 86.2, 0.27, 18, 0.8, 54.7, 0.37, 0.9, 0.93, 1385.43, 400000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'JREP', 179.4, 66.7, 0.7, 63.5, 0.1, 41.4, 0.6, 20.2, 0.8, 14, 0.7, 1563.76, 330000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'KREP', 285.2, 36.5, 0.1, 46, 0.43, 24.2, 0.73, 9.6, 0.73, 2.1, 0.83, 2120, 575000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'LREP', 17.6, 7.3, 0.9, 21.5, 0.57, 1.7, 0.87, 12.2, 0.67, 1, 1, 1250.54, 330000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'MREP', 26.7, 46.2, 0.6, 26.7, 0.57, 8.1, 0.87, 1.7, 0.9, 1.3, 1, 979.7, 350000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'NREP', 61.6, 20.8, 0.5, 1.7, 0.77, 11, 0.8, 7.4, 0.9, 49, 0.47, 3240.68, 1300000, 50)
INSERT into #pipelinehist VALUES ('12/18/2007 0:00', 'OREP', 31.6, 16.9, 0.63, 50.1, 0.43, 7.2, 0.87, 19.5, 0.7, 0.9, 0.97, 1303.48, 330000, 50)

View 3 Replies View Related

Sp Quotes

Apr 5, 2005

below is the code of my sp
it's giving my wrong result: 1 instead 0 and vice versa
could you please check what's wrong with it: i think there is something related to @var2 in the code colored in orange.

Thanks!


Code:

ALTER PROCEDURE sp_name
(
@param1 int = NULL,
@param2 int = NULL,
@Result int OUTPUT
)

AS

DECLARE @var1 AS varchar(255)
DECLARE @var2 AS varchar(255)
DECLARE @x AS varchar(1000)

IF @param1 IS NOT NULL
BEGIN
SET @var1 = (
SELECT t1col1
FROM tabl1
WHERE t1col2 = @param1)

SET @var2 = ''

DECLARE crsr CURSOR FOR

SELECT t2col1 FROM tabl2 WHERE t2col2 = @var1

OPEN crsr
FETCH NEXT FROM crsr INTO @x

WHILE @@FETCH_STATUS = 0
BEGIN
SET @var2 = @var2 + '''' + @x + '''' + ', '

FETCH NEXT FROM crsr INTO @x
END

CLOSE crsr
DEALLOCATE crsr

SET @var2 = SUBSTRING(@var2, 1, LEN(@var2) - 1)

END
ELSE
BEGIN
SET @var2 = (SELECT t2col1 FROM t2 WHERE tb2col3 = @param2)
SET @var2 = '''' + @var2 + ''''
END

PRINT @var2

IF EXISTS (SELECT * FROM tabl3 WHERE t3col1 IN (@var2))
OR
EXISTS (SELECT * FROM tabl4 WHERE t4col1 IN (@var2))
BEGIN
SET @Result = 1
END
ELSE
BEGIN
SET @Result = 0
END

View 1 Replies View Related

Quotes In Quotes..

Mar 19, 2008

Hi all,

How do you put quotes in quotes so it looks like this below?


exec('select IDENT_CURRENT('table')')

Not


exec('select IDENT_CURRENT('table')')



I just don't want the middle quotes to end the initial quote..



thanks in advance..

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved