Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Quotes in Stored Procedures

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-10-17 : 07:53:53
Sal writes "If I need to develope a string in a stored procedure which must be used in the Exec command and the string needs to have single quotes in it, how can it be done. I've tried two single quotes together, I've tried double quotes , etc.
Simple example. This example does not work in VS2005

Declare @Str as varchar(1000)
set @str = 'insert into test (LogDate) values ('10/06/2006')'
exec(@str)

I can't get the single quotes around the date field to appear in the @str variable

I am using VS2005 and SQL2000
Is there a setting I am missing or anything else.

Also can stored procedures use integer arrays. I've tried a few way to declare them, but it does not seem to work.

Sal"

Antonio
Posting Yak Master

168 Posts

Posted - 2006-10-17 : 08:14:12
quote:
Originally posted by AskSQLTeam

Sal writes "If I need to develope a string in a stored procedure which must be used in the Exec command and the string needs to have single quotes in it, how can it be done. I've tried two single quotes together, I've tried double quotes , etc.
Simple example. This example does not work in VS2005

Declare @Str as varchar(1000)
set @str = 'insert into test (LogDate) values ('10/06/2006')'
exec(@str)

I can't get the single quotes around the date field to appear in the @str variable

I am using VS2005 and SQL2000
Is there a setting I am missing or anything else.



Please refer to SET QUOTED_IDENTIFIER in BOL for further information.


quote:

Also can stored procedures use integer arrays. I've tried a few way to declare them, but it does not seem to work.

Sal"



You can you create a function and pass a table variable as input parameter.

_________________________________________________________________________________________________________________________
Inability is a disaster; patience is bravery; abstinence is a treasure, self-restraint is a shield; and the best companion is submission to Divine Will.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-17 : 12:18:47

http://www.sommarskog.se/dynamic_sql.html


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -