July 20, 1999

Embedded Spaces in Column Names

Question: I’ve inherited an Access database with embedded spaces in the column names. I use SQL with Visual Basic and want to select these columns and alias them so that I can address the columns in Visual Basic. For example, I have: Select Last Name as LastName From TABLE How

INSERT and ORDER BY in Creating Views

Question: I have a problem with Views. If I make this query: INSERT INTO ACHATSSELECT DISTINCT VINS_ACHAT.PRO, VINS_ACHAT.QtebouteilleFROM VINS_ACHAT then this is a good one. But if I want to make a view with this query like this: CREATE VIEW A_Ajout_achats ASINSERT INTO ACHATSSELECT DISTINCT VINS_ACHAT.PRO, VINS_ACHAT.QtebouteilleFROM VINS_ACHAT then there

Data Shaping (Passing Multiple Parameters)

Question: I am trying to use data shaping to get a recordset back. I was using two stored procedures that took one parameter each, but now I need to pass the second stored procedure a second parameter. Does data shaping allow for this type of querying? If so, what is

Field Names Are Invalid

Question: I’m using SQL queries in Delphi 4 to access a database. Some of the field names in the database are either reserved keywords or invalid in some way (for example, “%ON”). How do I get around this problem? Answer: Sorry, there is no easy way to fix this. You

Sorting by StartDateTime

Question: I have a field called StartDateTime. In Microsoft Access it contained only a time. My code used to sort this field properly when outputting, so that morning events appeared at the top. Since migrating to SQL Server, however, the field is now sorted by the first character, and the

Using a SQL Function to Return a Column Number

Question: Is it possible to return a number in a column, using a function, for each row in my result set? For example: “Select RowNum As Rw, Fname, Birth From Employee.” I am using Visual Basic 6.0. Answer: What you require is possible, and there are a couple of ways

Finding Table Names

Question: If I don’t know the table names beforehand, how do I get the table names out of the database? Answer: Use this: SELECT NAME FROM SYSOBJECTS WHERE TYPE = ‘U’

Adding Columns Via Data Ranges

Question: I have two tables, “grade” and “assignment”: TABLE FIELDgrade grade (char i.e. A..F) low_range high rangei.e. ‘A’, 80, 100 ‘B’, 60, 80 etc.assignment s_ref assign_no grade (numeric i.e. 78) I need to add the students’ grades (in character form) to Assignment to create a new view. I tried sub-queries


Question: What is the function of the DECLARE keyword in an SQL program? I am aware you can DECLARE cursors in embedded SQL. Are there any other instances where DECLARE is used in SQL? Answer: In general, the DECLARE keyword works as a placeholder to reserve space in memory for

No more posts to show