Solved

Need help creating a simple index on MS SQL Server

Posted on 2014-11-22
8
373 Views
Last Modified: 2014-11-23
Our website is hosted by web.com.  We have an plan that provides an MS-SQL server.
Since it is a hosted server, I can not index it with SMSS as I would my local server.

I have .asp code that runs on the server which queries the LOGSEARCH table of the InternetData database.

I need four indexes:

strSearchNumber,  SResult, OrderNumber, , and SDate.  

Can anyone help?
0
Comment
Question by:pcalabria
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40459344
Here's the MSDN page that shows the SQL for creating indexes: http://msdn.microsoft.com/en-us/library/ms188783.aspx
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40459358
Here's a simple ASP page that works with my SQLEXPRESS 2005 database.  You'll have to change the names of everything.
<%@ LANGUAGE = VBScript %>
<%  Option Explicit		%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Old Website List - ASP/MSSQL</title>
</head>
<body>
<!-- Display Header -->
<h2>Old Website List Index - ASP/MSSQL</h2>
<p>Creating Index Sortdex on websitelist</p>
<%
Dim connectstr, oConn, ndxrslt

connectstr = "Provider=SQLNCLI;Server=YOURSERVER\SQLEXPRESS;Database=YourDB;Uid=YourID; Pwd=YourPWD;"

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr

' --------- create index ---------------
Set ndxrslt = Server.CreateObject("ADODB.Recordset")
ndxrslt.Open "CREATE INDEX Sortdex ON websitelist (Sortname)", oConn

Set oConn = nothing
%>
</body>
</html>

Open in new window

0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 40459360
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:pcalabria
ID: 40459370
Thanks Dave, but I'm very confused.

First, my ASP code connects to the database, and works fine.  No problems here, in fact I prefer not to change the connection strings.  They took forever to figure out!

I may just be too green at MS SQL to understand the W3schools reference.  I guess the first question is to confirm that this should work with a shared hosting plan.  In other words, I do not have Admin privileges.

Secondly, if I can create an index in code where does the code go?  I've run transact SQL queries before, but that's it.

Can I open a query and use the code from W3?
0
 
LVL 7

Assisted Solution

by:Ray
Ray earned 250 total points
ID: 40459415
With most shared hosting service, you should have access to create database objects (tables, view, stored procedures).  Then you should be able to create indexes.

If you want to creat the index with code, just replace the transact sql queries (SELECT * from table1) with the following.

CREATE INDEX IX_strSearchNumber ON LOGSEARCH (strSearchNumber)
CREATE INDEX IX_SResult ON LOGSEARCH (SResult)
CREATE INDEX IX_OrderNumber ON LOGSEARCH (OrderNumber)
CREATE INDEX IX_SDate ON LOGSEARCH (SDate)

These will create 4 indexes on the LOGSEARCH table with the specific fields.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40459916
After changing the login info, my script works fine on my Godaddy hosting with SQLEXPRESS 2005.  I used the same login as I do for doing a SELECT or any other query.
0
 

Author Closing Comment

by:pcalabria
ID: 40460398
Thanks guys!
Dave, your links taught me so much about MS SQL that I did not know,
and Ray, you sure made things easy.  I copied and pasted your links into the query area, typed Go and my problem was solved!

Appreciate the help!
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40460402
You're welcome, glad to help.
0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question