MS SQL Server queries and qualifying square brackets [ ] being treated as global variables

Hi,

I’m having trouble with running Microsoft SQL Server queries that must be qualified using [ ] (square brackets). I have some really terrible work arounds, is there a standard way of bypassing this problem without using the nasty work arounds I’m resorting to?

eg. SELECT [full name], [place of origin], [street name] FROM [dbo].[A D B].[The Table Name] WHERE [full name] = [global variable full name]

Scriptcase treats every qualified object [ ] as a global variable meaning that the above query becomes unintelligible. SQL Server queries must be qualified using [ ] for its named objects where spaces exist.

The 3 work arounds I’ve discovered are,

  1. don’t use spaces in naming any field / table or object, this is impossible since we use 3rd party databases as well as our own. Our business uses almost exclusively SQL Server databases.
  2. for every named object with spaces in them, create a global variable in the initializing event of the application
  3. if coding in php directly, you could also use the escape sequence on the end closing ], i.e. “]” or do something like, $myvariable = “Select * from [table one”."]"

2 scenarios types of places this problem is affected by are in,

  • non php parts of applications, such as lookups and the SQL part of an application
  • in any manually written php code, such as in event.

Any help on this would be much appreciated. I am concerned that in the future scriptcase may decide to allow global variables to be created on the fly by parsing these variables and hence I would be back to square one!

If you set QUOTED_IDENTIFIER to ON you will be able to use " instead of []

eg. SET QUOTED_IDENTIFIER ON; (it need to be set only one time)

SELECT “full name”, “place of origin”, “street name” FROM “dbo”.“A D B”.“The Table Name” WHERE “full name” = [global variable full name]

That’s great! Thanks jlboutin60.