pcalabria
asked on
Need help creating a simple index on MS SQL Server
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?
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?
Here's the MSDN page that shows the SQL for creating indexes: http://msdn.microsoft.com/en-us/library/ms188783.aspx
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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
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?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
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!
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!
You're welcome, glad to help.