Solved

Need help creating a simple index on MS SQL Server

Posted on 2014-11-22
8
372 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

752 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