MsSQL 2005 Query Help

May 30, 2008

Code:

Select id from tbl_account in Game_User DB

id is binary data


USE Billing
INSERT INTO tblUser (userId,cpId,userTypeId,userStatusId,gameServiceId) VALUES ('test','1','1','9','6') where userId = id from tbl_account

and

INSERT INTO tblUserInfo (userNumber,userId,cpId,userTypeId,userStatusId,gameServiceId) VALUES ('123','test','1','1','9','6') where userNumber = userNumber and userId = userId from tblUser



Im new when it comes to making SQL queries, so i need help badly.

Basically what i need the query to do is call from a DB "User" id where the id is in Binary data. from that i need it to insert into 2 other tables in the Billing DB.

the UserId needs to be the same in all areas, and when it inserts into tblUserInfo it has to pull from userNumber from tblUser after the rows are entered so that the userNumber in tblUser and tblUserInfo are the same.

Hopefully you can help. if any further information is needed please just ask and ill try to give as much as i know.

Thanks

David

View 2 Replies


ADVERTISEMENT

Deploying MSSQL 2005 Express DB To MSSQL 2005 WKGP Errors

Sep 29, 2006

DB is developed on local computer with MSSQL 2005 Express. My host is on MSSQL 2005 workgroup. Are they compatible, because I am getting errors? Is my approach wrong?

I have tried several approaches.

A) I created a backup of database on my local, then placed a copy on the server. Then I tried to restore through Server Management Studio. I get this error.

TITLE: Microsoft SQL Server Management Studio

------------------------------

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

ADDITIONAL INFORMATION:

The backed-up database has on-disk structure version 611. The server supports version 539 and cannot restore or upgrade this database.

RESTORE FILELIST is terminating abnormally. (Microsoft SQL Server, Error: 3169)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=08.00.2039&EvtSrc=MSSQLServer&EvtID=3169&LinkId=20476

------------------------------

BUTTONS:

OK

------------------------------



B: I also have tried copying the database. I put it in the same path as the other databases that can be read with server management studio on the server. Then, tried to get to it through server managements studio and it did not appear. So I tried to attach it. Then I received this error:

TITLE: Microsoft SQL Server Management Studio

------------------------------

Attach database failed for Server 'MROACH1'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.2047.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attach+database+Server&LinkId=20476

------------------------------

ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

Could not find row in sysindexes for database ID 10, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.

Could not open new database 'LodgingDB'. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 602)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=602&LinkId=20476

------------------------------

BUTTONS:

OK

------------------------------

C: I have also tried opening the Database, and back up file through Server Management Studio. without success.

D: I also tried Windows and Software update at microsoft update, but no updates were recommended for Version on Server.

I'm surprised this is so hard. My original data base was created in same family of software. 2005 MS SQL Express. I could use some direct help from someone experienced with this. Am I doing it wrong or are the DB versions incompatible.

Mark Roach





View 5 Replies View Related

Server Configuration For MSSQL 2000 And MSSQL 2005

Sep 6, 2006

Does enabling/disabling Data Execution Prevention have a performanceimpact on SQL 2000 or SQL 2005?For SQL best performance - how should I configure for:Processor Scheduling:Programs or Background servicesMemory Usage:Programs or System Cache

View 9 Replies View Related

Creating Index In MSSQL 2000 From MSSQL 2005

Mar 24, 2008

Hi,

I am a bit new to the MSSQL server. In our application, we use so many SQL queries. To imporve the performance, we used the Database enigine Tuning tool to create the indexes. The older version of the application supports MSSQL 2000 also. To re-create these new indexes, I have an issue in running these "CREATE INDEX" commands as the statements generated for index creation are done in MSSQL 2005. The statements include "INCLUDES" keyword which is supported in MSSQL 2005 but not in MSSQL 2000.

Ex:-

CREATE INDEX IND_001_PPM_PA ON PPM_PROCESS_ACTIVITY

(ACTIVITY_NAME ASC, PROCESS_NAME ASC, START_TIME ASC, ISMONITORED ASC)

INCLUDE

(INSTANCE_ID, ACTIVITY_TYPE, STATUS, END_TIME, ORGANIZATION);


Any help in creating such indexes in 2000 version is welcome.

Thanks,
Suresh.

View 2 Replies View Related

Generating Script For MSSQL 2000 From MSSQl 2005?

May 3, 2008

Hello
We are using SQL 2005 and now we are planning to use SQL 2000. what are the ways to do the process.

We taken the script spcificall for 2000 and run it in SQL 200. But we are getting the error in SCRIPT?

Could you please give me the step to do?

Thanks,
Sankar R

View 6 Replies View Related

Migrate MSSQL 2005 Express -&&> MSSQL 2005 Srv

Apr 25, 2006

Hi!

What is the best way to migrate MSSQL 2005 Express -> MSSQL 2005 Srv?

View 4 Replies View Related

MSSQL Express 2005 Vs. MSSQL 2000

Jun 15, 2006

Ben writes "I have a sql script that doesn't function very well when it's executed on a SQL 2000 server.

The scrpt looks like this:


---------------------------------------------------------------------------------------------------
USE [master]
GO
IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE loginname = N'SSDBUSERNAME')
EXEC sp_addlogin N'SSDBUSERNAME', N'SSDBPASSWORD'
GO
GRANT ADMINISTER BULK OPERATIONS TO [SSDBUSERNAME]
GO
GRANT AUTHENTICATE SERVER TO [SSDBUSERNAME]
GO
GRANT CONNECT SQL TO [SSDBUSERNAME]
GO
GRANT CONTROL SERVER TO [SSDBUSERNAME]
GO
GRANT CREATE ANY DATABASE TO [SSDBUSERNAME]
GO
USE [master]
GO
If EXISTS (Select * FROM master.dbo.syslogins WHERE loginname = N'SSDBUSERNAME')
ALTER LOGIN [SSDBUSERNAME] WITH PASSWORD=N'SSDBPASSWORD'
GO
GRANT ADMINISTER BULK OPERATIONS TO [SSDBUSERNAME]
GO
GRANT AUTHENTICATE SERVER TO [SSDBUSERNAME]
GO
GRANT CONNECT SQL TO [SSDBUSERNAME]
GO
GRANT CONTROL SERVER TO [SSDBUSERNAME]
GO
GRANT CREATE ANY DATABASE TO [SSDBUSERNAME]
GO
USE [master]
GO
IF EXISTS (select * from dbo.sysdatabases where name = 'ISIZ')
DROP DATABASE [ISIZ]
GO
USE [SurveyData]
GO
exec sp_adduser 'SSDBUSERNAME'
GRANT INSERT, UPDATE, SELECT, DELETE
TO SSDBUSERNAME
GO
USE [SurveyManagement]
GO
exec sp_adduser 'SSDBUSERNAME'
GRANT INSERT, UPDATE, SELECT, DELETE
TO SSDBUSERNAME
---------------------------------------------------------------


I need to be converted to a script that can be executed on both MSSQL 2000 and MSSQL 2005.

I was wondering if somebody there could help me with this problem?!

Thanks,
Ben"

View 1 Replies View Related

Migration MSSQL 2000 32-bit To MSSQL 2005 64-bit

Nov 17, 2007

I've been tasked to move our production databases on MSSQL 2000 to 2005. I've supported MSSQL since version 6.5 and performed migrations to successor versions.

Current Environment is MSSQL 2000 32-bit with current Service Packs.

I've performed mock migrations on Test servers upgrading all Production instances simultaneously from MSSQL 2000 to 2005 32-bit. The Test environment is identical to Production minus server name, IP etc. Also I have a separate server with MSSQL 2005 installed where I use the DETACH / ATTACH and BACKUP / RESTORE method for migration / acceptance testing. There are approximately 30 databases totaling 70 GB. This has gone as expected and fairly successful. Vendors have been coordinated with to update code and staff for acceptance testing.

I'd prefer going directly to MSSQL 2005 64-bit instead if possible due to memory benefits etc. This is where I'd like some feedback prior to borrowing a 64-bit server for testing.

Upgrade options:

1. Is it better to migrate from MSSQL 2000 32-bit to 2005 64-bit via:
a. DETACH / ATTACH
b. BACKUP / RESTORE
c. Is one method more advantageous relating to the end result?
2. Regarding XP clients, have issues been experienced with the default SQL Server driver or is an alternate recommended for XP clients to connect to a MSSQL 64-bit server databases?
3. If you have performed this migration and have relevant experience please pass them along.

View 3 Replies View Related

Conversion Of MSSql 2000 Database To MSSQL 2005 Database

Jan 18, 2008

How to convert a database in MSSQL 2000 to MSSQL 2005 database.Is there any tool or documentation available for this?

View 3 Replies View Related

MSSQL 2005 Vs. Visual Studio 2005 Service Pack 1

Mar 14, 2007

Hi,
for some reason, when I've installed visual studio 2005, I didn't install also SQL server.
Than I've updated VS with Service Pack 1 (thank god, I was trying unsucesfully for about 2 weeks :/ ).

Than I want to install MSSQL 2005 and an error came up:

Message displayed to user
SQL Server 2005 Setup has detected incompatible components from beta versions of Visual Studio, .NET Framework, or SQL Server 2005. Use Add or Remove Programs to remove these components, and then run SQL Server 2005 Setup again. For detailed instructions on uninstalling SQL Server 2005, see the SQL Server 2005 Readme.
SQL Server Setup has detected that the following required component is not installed: Microsoft Windows Installer 3.1. To proceed, download and install the Windows Installer 3.1 Redistributable from http://go.microsoft.com/fwlink/?LinkId=50380 , and then run SQL Server Setup again.

1. The http link leads to main page of MS Download Centre.
2. I have Installer 3.1. (version of file c:windowssystem32msiexec.exe said so)
3. I really do not have any beta version of any mentioned SW. I never had.

So I think the issue could be, that installer is checking for not updated version of Visual Studio.
(I was searching through net/msdn and seems no one had this problem (maybe wrong keywords, though) ).

I'm running setup.exe from CD1.

Uninstalling of VS Service Pack 1 is not an option. I really don't want to spent another week by installing it.
Please tell that there is some another way :) .
Thanks a lot.

Here are some logs:

SQLSetup0001_COMP_Datastore.xml

<Datastore>
<Scope Type="SetupBootstrapOptionsScope" Id="2336">
<Property Id="QuietSwitchPresent">0</Property>
<Property Id="LogSwitchPresent">0</Property>
<Property Id="ErrorReporting">0</Property>
<Property Id="DeleteManifestFileMode">1</Property>
<Property Id="MultiInstanceEnabled">0</Property>
<Property Id="ComponentUpdateOnly">0</Property>
<Property Id="ReducedUI">0</Property>
<Property Id="PatchedSetup">0</Property>
<Property Id="LocalSetup">0</Property>
<Property Id="InitiateReboot">0</Property>
<Property Id="HostSetup">1</Property>
<Property Id="RemoteMode">0</Property>
<Property Id="Remote">0</Property>
<Property Id="LoosenedSccChecks">{ }</Property>
<Property Id="DisabledSccChecks">{ }</Property>
<Property Id="LocalRebootPending">1</Property>
<Property Id="CmdLine">********</Property>
<Property Id="InstallMediaPath">Y:</Property>
</Scope>
<Scope Type="SetupStateScope" Id="">
<Property Id="machineName">COMP</Property>
<Property Id="logDirectory">C:Program FilesMicrosoft SQL Server90Setup BootstrapLOG</Property>
<Property Id="logSummaryFilename">C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGSummary.txt</Property>
<Property Id="logSequenceNumber">1</Property>
<Property Id="primaryLogFiles">{ ["C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0001_COMP_Core.log"], ["C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGSummary.txt"] }</Property>
<Property Id="watsonFailedAction">PerformSCCAction2</Property>
<Property Id="watsonFailedActionErrorCode">87</Property>
<Property Id="watsonFailedFunction">sqls::PerformSCCAction::perform</Property>
<Property Id="watsonFailedFunctionErrorCode">87</Property>
<Property Id="watsonSourceFileAndLineNo">setupsqlsetupactions.cpp@1390</Property>
<Property Id="watsonModuleAndVersion">setup.exe@2005.90.1399.0</Property>
<Property Id="watsonMsi">None</Property>
<Property Id="watsonMsiAndVersion">None</Property>
<Property Id="watsonSourceFile">setupsqlsetupactions.cpp</Property>
</Scope>
</Datastore>


SQLSetup0001_COMP_Core.log

Microsoft SQL Server 2005 Setup beginning at Wed Mar 14 18:23:08 2007
Process ID : 2336
Y:setup.exe Version: 2005.90.1399.0
Running: LoadResourcesAction at: 2007/2/14 18:23:8
Complete: LoadResourcesAction at: 2007/2/14 18:23:8, returned true
Running: ParseBootstrapOptionsAction at: 2007/2/14 18:23:8
Loaded DLL:Y:xmlrw.dll Version:2.0.3604.0
Complete: ParseBootstrapOptionsAction at: 2007/2/14 18:23:8, returned true
Running: ValidateWinNTAction at: 2007/2/14 18:23:8
Complete: ValidateWinNTAction at: 2007/2/14 18:23:8, returned true
Running: ValidateMinOSAction at: 2007/2/14 18:23:8
Complete: ValidateMinOSAction at: 2007/2/14 18:23:8, returned true
Running: PerformSCCAction at: 2007/2/14 18:23:8
Complete: PerformSCCAction at: 2007/2/14 18:23:8, returned true
Running: ActivateLoggingAction at: 2007/2/14 18:23:8
Complete: ActivateLoggingAction at: 2007/2/14 18:23:8, returned true
Delay load of action "DetectPatchedBootstrapAction" returned nothing. No action will occur as a result.
Action "LaunchPatchedBootstrapAction" will be skipped due to the following restrictions:
Condition "EventCondition: __STP_LaunchPatchedBootstrap__2336" returned false.
Running: PerformSCCAction2 at: 2007/2/14 18:23:8
Error: Action "PerformSCCAction2" threw an exception during execution.
Return Code: 87
Message displayed to user
SQL Server 2005 Setup has detected incompatible components from beta versions of Visual Studio, .NET Framework, or SQL Server 2005. Use Add or Remove Programs to remove these components, and then run SQL Server 2005 Setup again. For detailed instructions on uninstalling SQL Server 2005, see the SQL Server 2005 Readme.
SQL Server Setup has detected that the following required component is not installed: Microsoft Windows Installer 3.1. To proceed, download and install the Windows Installer 3.1 Redistributable from http://go.microsoft.com/fwlink/?LinkId=50380 , and then run SQL Server Setup again.

Class not registered.
Running: UploadDrWatsonLogAction at: 2007/2/14 18:23:9
Message pump returning: 87

View 2 Replies View Related

Converting SQL Express 2005 To MSSQL 2005 Database

Jul 14, 2007

Hello, im shure this must have been up before and i apologize for that. But i wonder if there is a way to convert the SQL server express databases to MSSQL 2005 databses?

View 3 Replies View Related

MSSQL Query Help

Dec 9, 2004

Having problem completing this query. I have a list of items. Some items need to be grouped by a list, some by a range. I was thinking of useing two tables, one for the items, and one for the groups. The groups would have something like groupid, title, listnumbers, rangelow, and rangehigh. The tables are in sql database. For example:
The list of items numbers are 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20. In the group table, it would be listed like this:
G1, Group1, 1,,
G1, Group1, 6,,
G2, Group2, ,2,5
G3, Group3,6,18,20
G3, Group3,7,15,17
G3, Group3,8,14,16
G3, Group3,9,11,13

In this example, Group1 is a list, group2 is a range, and group3 is a list of ranges. I can make a query that pulls all the items just in the groups:
SELECT ECC_ITEMS.NBR, Group.Group_Name, Group.Title, ECC_ITEMS.DESCR, ECC_ITEMS.REG_PRC
FROM Group, ECC_ITEMS
WHERE ECC_ITEMS.NBR Between Group.RangeLow And Group.RangeHigh Or ECC_ITEMS.NBR=Group.GroupItems
Now, I am not sure how to put the rest of the items (the ones that aren't in a group) in that query. I was thinking on making a union and the second query being a unmatched query. Not sure how to make it were that query is "unmatched" with a table in the same query. And ideas on how to make the second part of the union query?

View 3 Replies View Related

MSSQL 2005

Feb 16, 2007

Hi Guys.If i didnt use MSSQL 2005 Express (say my database was bigger than 4 gig), what license would i need to get for the full version?I'm slightly confused with the CALS (who isnt?).If its on the same server and only IIS / asp.net accessing the database do I only need say 2 CALS?1 for read only1 for read / writewhich I then use ASP.NET to talk to the database?Or do I have to get a per processor license.I would appreciate any help  

View 2 Replies View Related

Enquiry On MSSQL Query

Jan 18, 2008

in mysql, we can have

select * from test where date like '%-02-01'

all result that ends with -02-01 will be displayed.

however, if i want to do it in ms sql, may i know what's the syntax for this select....like ?

Thanks.

View 1 Replies View Related

Mssql Query Sender

May 7, 2007

i am familiar with php mySql combo, but from now on the boss wants me on MS SQL. i have a little query sender that used mySql and i tried to switch it over to use mssql_functions like:
php Code:






Original
- php Code




mssql_connect($host,$user,$password);
mssql_select_db($_POST['database']);
mssql_query($cxn,$_POST['query']);
mssql_num_rows($result) == 0;






mssql_connect($host,$user,$password);mssql_select_db($_POST['database']);mssql_query($cxn,$_POST['query']);mssql_num_rows($result) == 0;


When i run my script i get a blank screen. I am already bent out of shape trying to switch from mySql to this. any help would be appreciated. here is my code...

php Code:






Original
- php Code




<?php
/*Program: mssql_send.php
*Desc: PHP program that sends an SQL query to the
* MS SQL server and displays the results.
*/
echo "<html>
<head><title>MSSQL Query Sender</title></head>
<body>";
if(ini_get("magic_quotes_gpc") == "1")
{
$_POST['query'] = stripslashes($_POST['query']);
}
$host="yourhost";
$user="you";
$password="example";

/* Section that executes query and displays the results */
if(!empty($_POST['form']))
{
$cxn = mssql_connect($host,$user,$password);
mssql_select_db($_POST['database']);
$result = mssql_query($cxn,$_POST['query']);
echo "Database Selected: <b>{$_POST['database']}</b><br>
Query: <b>{$_POST['query']}</b>
<h3>Results</h3><hr>";
if($result == false)
{
echo "<h4>Error!</h4>";
}
elseif(mssql_num_rows($result) == 0)
{
echo "<h4>Query completed.
No results returned.</h4>";
}
else
{
/* Display results */
echo "<table border='1'><thead><tr>";
$finfo = mssql_fetch_field($result);
foreach($finfo as $field)
{
echo "<th>".$field->name."</th>";
}
echo "</tr></thead>

<tbody>";
for ($i=0;$i < mssql_num_rows($result);$i++)
{
echo "<tr>";
$row = mssql_fetch_row($result);
foreach($row as $value)
{
echo "<td>".$value."</td>";
}
echo "</tr>";
}
echo "</tbody></table>";
}
/* Display form with only buttons after results */
$query = str_replace("'","%&%",$_POST['query']);
echo "<hr><br>
<form action='{$_SERVER['PHP_SELF']}' method='POST'>
<input type='hidden' name='query' value='$query'>
<input type='hidden' name='database'
value={$_POST['database']}>
<input type='submit' name='queryButton'
value='New Query'>

<input type='submit' name='queryButton'
value='Edit Query'>
</form>";
exit();
}

/* Displays form for query input */
if (@$_POST['queryButton'] != "Edit Query")
{
$query = " ";
}
else
{
$query = str_replace("%&%","'",$_POST['query']);
}
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>"
method="POST">
<table>
<tr><td style='text-align: right; font-weight: bold'>
Type in database name</td>
<td><input type="text" name="database"
value=<?php echo @$_POST['database'] ?> ></td>
</tr>

<tr><td style='text-align: right; font-weight: bold'
valign="top">Type in SQL query</td>
<td><textarea name="query" cols="60"
rows="10"><?php echo $query ?></textarea></td>
</tr>
<tr><td colspan="2" style='text-align: center'>
<input type="submit" value="Submit Query"></td>
</tr>
</table>
<input type="hidden" name="form" value="yes">
</form>

</body></html>






<?php/*Program:  mssql_send.php *Desc:     PHP program that sends an SQL query to the *          MS SQL server and displays the results. */echo "<html>      <head><title>MSSQL Query Sender</title></head>      <body>";if(ini_get("magic_quotes_gpc") == "1"){   $_POST['query'] = stripslashes($_POST['query']);}$host="yourhost";$user="you";$password="example"; /* Section that executes query and displays the results */if(!empty($_POST['form'])){  $cxn = mssql_connect($host,$user,$password);  mssql_select_db($_POST['database']);  $result = mssql_query($cxn,$_POST['query']);  echo "Database Selected: <b>{$_POST['database']}</b><br>        Query: <b>{$_POST['query']}</b>        <h3>Results</h3><hr>";  if($result == false)  {     echo "<h4>Error!</h4>";  }  elseif(mssql_num_rows($result) == 0)  {     echo "<h4>Query completed.             No results returned.</h4>";  }  else  {   /* Display results */     echo "<table border='1'><thead><tr>";     $finfo = mssql_fetch_field($result);     foreach($finfo as $field)     {        echo "<th>".$field->name."</th>";     }     echo "</tr></thead>           <tbody>";     for ($i=0;$i < mssql_num_rows($result);$i++)     {        echo "<tr>";        $row = mssql_fetch_row($result);        foreach($row as $value)        {           echo "<td>".$value."</td>";        }        echo "</tr>";     }     echo "</tbody></table>";  }  /* Display form with only buttons after results */  $query = str_replace("'","%&%",$_POST['query']);  echo "<hr><br>      <form action='{$_SERVER['PHP_SELF']}' method='POST'>        <input type='hidden' name='query' value='$query'>        <input type='hidden' name='database'               value={$_POST['database']}>        <input type='submit' name='queryButton'               value='New Query'>        <input type='submit' name='queryButton'               value='Edit Query'>      </form>";  exit();}  /* Displays form for query input */if (@$_POST['queryButton'] != "Edit Query"){   $query = " ";}else{   $query = str_replace("%&%","'",$_POST['query']);}?><form action="<?php echo $_SERVER['PHP_SELF'] ?>"       method="POST"><table> <tr><td style='text-align: right; font-weight: bold'>         Type in database name</td>      <td><input type="text" name="database"            value=<?php echo @$_POST['database'] ?> ></td> </tr>  <tr><td style='text-align: right; font-weight: bold'          valign="top">Type in SQL query</td>     <td><textarea name="query" cols="60"            rows="10"><?php echo $query ?></textarea></td> </tr> <tr><td colspan="2" style='text-align: center'>        <input type="submit" value="Submit Query"></td> </tr></table><input type="hidden" name="form" value="yes"></form> </body></html>

View 2 Replies View Related

SHOW Query For MSSQL

Sep 18, 2004

What would the MySQL equivalent for "SHOW TABLES" and "SHOW FIELDS" be in MSSQL?

View 8 Replies View Related

Help With Tricky Query In MSSQL

Apr 18, 2004

Let's say that I have three tables:

Buyer
------
ID
Name
Adress

Session
-------
ID
Date
Pageviews
Buyer

Orders
-------
ID
DatePaid
Session

Now, I've been racking my brain on how to list the Buyers and the number of related rows in the Orders table. Add to this that I only want to count the Orders where DatePaid IS NOT NULL.

Any help would be enourmously appriceated.

View 3 Replies View Related

MSSQL Query Merging...?

May 2, 2007

I have this database running (ignore that that was done in Access, this is being made in Microsoft SQL Server 2005).


What I need to do is if you look at the tbl_events table and the tbl_timekeeperDetails table I need to make a query that:

Lists the names of all timekeepers (whether they are booked for a meeting or not), and the meetings at which they are timekeeping.

The tricky part of this is getting the query to show the timekeepers who aren't assigned to an event.

I have two seperate querys so far, but I'm presuming there must be a way of merging them or something.

I have this code so far:
select timekeeperTitle,timekeeperNameFirst,timekeeperNameLast,eventID
from timekeeperDetails,events
where timekeeperDetails.timekeeperID = events.timekeeperID
select timekeeperTitle,timekeeperNameFirst,timekeeperNameLast
from timekeeperDetails

If anyone has any ideas, please do post a reply or email me at paul [at] abscond [dot] org

It would be very much appreciated.

View 3 Replies View Related

MySQL To MsSQL 2005

Nov 5, 2007

Hi!
How can i convert this code to work with MsSQL 2005?
/Tomas
 Partial Class skaalb
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strConnectionString As String
Dim strQuery As String
Dim MyConnection As OdbcConnection
Dim myCommand As OdbcCommand


Dim path As String = Server.MapPath("~/album") & "/"
Dim albName As String = Trim(Replace(txtAlbum.Text, "'", "''"))
Dim folderName As String = Trim(Replace(txtAlbum.Text, "'", "''"))
folderName = Replace(folderName, " ", "_")


Try
If Not My.Computer.FileSystem.DirectoryExists(path & folderName) Then

My.Computer.FileSystem.CreateDirectory(path & folderName)
labelStatus.Text = "Folder <b>" & folderName & "</b> created!"

Dim Beskrivning As String = Trim(Replace(txtBeskrivning.Text, "'", "''"))

strConnectionString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=xxxxxxxx; DATABASE=xxxxxxx; UID=xxxxxxxx; PASSWORD=xxxxxxxxx; OPTION=3"
MyConnection = New OdbcConnection(strConnectionString)
MyConnection.Open()
strQuery = "INSERT INTO tbl_albumet(alb_Namn, alb_Beskrivning, alb_Mapp) VALUES (?, ?, ?)"

myCommand = New OdbcCommand(strQuery, MyConnection)
myCommand.Parameters.AddWithValue("?", albName)
myCommand.Parameters.AddWithValue("?", Beskrivning)
myCommand.Parameters.AddWithValue("?", folderName)


myCommand.ExecuteNonQuery()
MyConnection.Close()


Else
labelStatus.Text = "Folder excist, pick another name!"
End If
Catch ex As Exception
labelStatus.Text = "Unable to create folder!"
End Try


End Sub
End Class 

View 1 Replies View Related

IDENTITY_INSERT In MSSQL 2005

Oct 29, 2007

Hi ,

I use MSsql server 2005 with the compatability mode set to 2000.One of the tables, has an IDENTITY Column.I need to restore a earlier backed copy of the table.So, i did the following :

set IDENTITY_INSERT MYTABLE ON

insert into MYTABLE(ID,NAME) values(23,'XYZ')

However, i get the following error :

[Error Code: 544, SQL State: S0001] Cannot insert explicit value for identity column in table 'MYTABLE' when IDENTITY_INSERT is set to OFF.

Can anyone tell me why the set IDENTITY_INSERT does not work ? I need to disable the IDENTITY, do the restore and then enable the IDENTITY again.Also, i need to be able to do this only thorugh SQL issued via JDBC.Please help.

Thanks,

View 3 Replies View Related

IDENTITY_INSERT In MSSQL 2005

Oct 26, 2007

Hi ,

I use MSsql server 2005 with the compatability mode set to 2000.One of the tables, has an IDENTITY Column.I need to restore a earlier backed copy of the table.So, i did the following :

set IDENTITY_INSERT MYTABLE ON

insert into MYTABLE(ID,NAME) values(23,'XYZ')

However, i get the following error :

[Error Code: 544, SQL State: S0001] Cannot insert explicit value for identity column in table 'MYTABLE' when IDENTITY_INSERT is set to OFF.

Can anyone tell me why the set IDENTITY_INSERT does not work ? I need to disable the IDENTITY, do the restore and then enable the IDENTITY again.Also, i need to be able to do this only thorugh SQL issued via JDBC.Please help.

Thanks,
Charu.

View 1 Replies View Related

ODBC 3.x MsSql 2005

May 6, 2008

First off, Devshed is a great place to find information for development. I'm on here daily looking through threads, finding answeres

I'm building a backend for a program that uses msSql 2005 and ODBC .
I'm trying to insert into a table, and it is working, but i would like to find a solution to this error i get from the odbc trace:

Calc f54-5c4ENTER SQLExecute
HSTMT 00924A18

Calc f54-5c4EXIT SQLExecute with return code -1 (SQL_ERROR)
HSTMT 00924A18

DIAG [22018] [Microsoft][SQL Native Client]Invalid character value for cast specification (0)

when i try to insert a value of 0 (zero) into a column that is bound as a double it gives this error.

And one more thing:
if(retcode != SQL_SUCCESS | SQL_SUCESS_WITH_INFO)

shouldnt that work? (if Retcode isnot success OR success_with_info)

Any input would be greatly appreciated!
thanks

View 2 Replies View Related

UTF-8 Coding Of MSSQL 2005 DB

Mar 26, 2008

Hi List,I am searching franticly for a solution (or the procedure) to settingthe coding of a new DB to UTF-8. I can find no setting in the ServerManager, during creation of the DB, to influence this. Can someoneplease show me the way? Thanks--Shawn

View 3 Replies View Related

Setting Up MSSQL 2005

Nov 27, 2006

hi all,

My company has finally decided to go with MSSQL 2005.

now i havent used mssql since version 7.. which was a while ago..

whats the difference in terms of the setup and the easy of use ?

View 4 Replies View Related

How Do I Add Licenses To MSSQL 2005?

Mar 14, 2008

I've purchased and installed SQL Server 2005 along with some licenses and I now have a 'Microsoft Open License Confirmation Letter' in my inbox.

How do I add these licenses to SQL Server and get them active?

How do I check to see how many licenses SQL Server contains?

View 10 Replies View Related

From MySQL To MSSQL 2005

Dec 12, 2005

Hello! I'm installing the MSSQL 2005.

View 24 Replies View Related

MDF Database To MSSQL 2005

May 13, 2007

I'm pretty new at this so bear with med



I've made af site in Visual Web Developer. On that site i've made a database and it worked finde when I first uploaded it to my FTP as a database file on the server. But due to security problems, my web hotel host has deactivated that possibility. Så now I have to put my data and tables into the MSSQL 2005 Database the host uses. Now here's the problem.



1: How do I do that?



2: How do I get tha tables I've made i Visual Web Developer over in SQL Server Management Studio Express så that I can upload it?

View 6 Replies View Related

SSIS In MSSQL 2005

May 4, 2006

Currently exploring MSSQL 2005 and running into following problem:

I installed MSSQL 2005 Eval (version 9.0.1399) on Windows XP (strictly not supported). Installation runs oke, dbserver is up and now I want to export data from an Informix database instance. I created a test database and ODBC link, but when trying to copy tables, I run into following error:

Could not set up data flow connections... The connection type "OLEDB" specified for connection manager {very long registry key} is not recognized as a valid connection manager type.

This message can be okayed, but then following error pops up:

The connection "DataReaderSrc" is not found.

In the report, following details:

Operation stopped...

- Initializing Data Flow Task (Success)

- Initializing Connections (Success)

- Setting SQL Command (Success)

- Setting Source Connection (Error)



Messages

The connection "DataReaderSrc" is not found. This error is thrown by Connections collection when the specific connection element is not found.
({7574B30E-EF48-4B53-BA5C-40F2B66C332E})


- Setting Destination Connection (Stopped)

- Validating (Stopped)

- Prepare for Execute (Stopped)

- Pre-execute (Stopped)

- Executing (Stopped)

- Copying to [Gerrit].[dbo].[orders] (Stopped)

- Post-execute (Stopped)

- Cleanup (Stopped)

Does anyone know what to do?

Thanks,

View 4 Replies View Related

New To Mssql Problem With Query Conversion

Jul 22, 2004

im managing most queries without any problems (im converting from access to mssql) but this one is causing me grief - how do i put this into mssql ?



SELECT dbo_Personal.ID, dbo_Personal.Surname1, dbo_Lead.SourceOfLead, dbo_Lead.DateOfLead, dbo_Mortgage.MortgageAppSubmitted, dbo_Mortgage.MortgageOfferedAccepted, dbo_Mortgage.MortgageDrawndown, dbo_Mortgage.MortgageApplicationClosed,
[dbo_Mortgage.MortgageCommissionAnticipated]+[dbo_Life.LifeCommissionAnticipated]+[dbo_BuildingsAndContents.BandCCommissionAnticipated]+[dbo_OtherBusiness.OtherBusinessCommissionAnticipated] AS Expr1,

[dbo_commissions.MortgageCommissionReceived]+[dbo_commissions.LifeCommissionReceived]+[dbo_commissions.BandCCommissionReceived]+[dbo_commissions.OtherBusinessCommissionReceived] AS Expr2

, IIf([Expr1]<1000,[Expr1]*0.3,IIf([Expr1]<2000,[Expr1]*0.4,[Expr1]*0.5)) AS Expr3
, IIf([Expr2]<1000,[Expr2]*0.3,IIf([Expr2]<2000,[Expr1]*0.4,[Expr2]*0.5)) AS Expr4

FROM (((((dbo_Personal INNER JOIN dbo_Lead ON dbo_Personal.ID = dbo_Lead.ID) LEFT JOIN dbo_Mortgage ON dbo_Personal.ID = dbo_Mortgage.ID) LEFT JOIN dbo_OtherBusiness ON dbo_Personal.ID = dbo_OtherBusiness.ID) LEFT JOIN dbo_BuildingsAndContents ON dbo_Personal.ID = dbo_BuildingsAndContents.ID) LEFT JOIN dbo_Commissions ON dbo_Personal.ID = dbo_Commissions.ID) LEFT JOIN dbo_Life ON dbo_Personal.ID = dbo_Life.ID
WHERE (((dbo_Lead.SourceOfLead) Like "Solutions*"));

View 9 Replies View Related

ACCESS To MSSQL Update Query

Oct 24, 2005

I run the following statement from an update query in access but I can't find the way to run this same query in MSSQL. Please give me some ideas how to modify and run this in MSSQL.

Thank you

"UPDATE DISTINCTROW ZipToTerr, leadsUS SET leadsUS.Terr = [ZipToTerr]![TerrNum] WHERE ((([ZipToTerr].[BU]='W') AND (([ZipToTerr].[ZipFrom])<=[zip]) And (([ZipToTerr].[ZipTo])>=[zip])) And (([leadsUS].[terr]) = 1 ));"

View 8 Replies View Related

Mssql Query Similar To Unix_timestamp

Jan 18, 2007

Hi

I have a mysql query in my php script like
UNIX_TIMESTAMP() - UNIX_TIMESTAMP(sessioncreated) as sessionspan .
What is the equivalent of above query in mssql. I need the same query in mssql. Is there any function that does the same action in mssql2000.

Thanks in Advance.
stranger

View 3 Replies View Related

Help With MSSQL Query That Takes Hours To Run

Mar 21, 2007

I have 3 tables, that appear as follows (insignificant fields are not mentioned for brevity):

RETAIL(code, CurrentLocation) ~ 2.6 million records

LOCAUDIT(code, Date, Time, Location) ~ 3.6 million records

STAFF(ID, NAME) ~ 40K records

Each record in the RETAIL table represents a document. The LOCAUDIT table maintains history information for documents: locations they've been to. A location can be represented by a staff (from STAFF table), or an unlimited range of different names - not enumerated in a table.

The query we run tries to find the currentlocation for each document in the RETAIL table (if any). Since a document may have been to many location, I'm interested in the last location which has the max Date,Time.

To perform the query, I created two views:

HISTORY
=======
CREATE VIEW HISTORY
AS
SELECT CODE, "DATE", TIME, CAST("DATE" + ' ' + TIME AS datetime) AS UpdateDateTime, LOCATION
FROM LOCAUDIT

LASTHISTORY
==========
CREATE VIEW LASTHISTORY
AS
SELECT CODE, Max(UpdateDateTime) AS LastUpdated
FROM HISTORY
GROUP BY CODE

UPDATE RETAIL
SET CURRENTLOCATION = (CASE WHEN t3.NAME IS NULL THEN t2.LOCATION ELSE t3.NAME END)
FROM RETAIL AS t4
LEFT JOIN LASTHISTORY AS t1 ON (t4.CODE = t1.CODE)
LEFT JOIN HISTORY AS t2 ON (t1.ITEM = t2.ITEM AND t1.LastUpdated = t2.UpdateDateTime)
LEFT JOIN STAFF AS t3 ON (t2.LOCATION = t3.ID)


What the query does is update the current location of each document. If the current location is a staff, we find the name of the staff member (hence the case).

In addition to clustered indexes on the primary keys, I've also created an index on (Code, Date, Time) on LOCAUDIT.

However, the query still seems to take up to 3 hours sometimes to run on a server with 4 CPU's and a whole bunch of memory. Can anyone suggest some way to improve this, add more effective indexes, or rewrite the queries all together. Any help is appreciated..

View 4 Replies View Related

How Do I Create A Ranking Query In MSSQL

Feb 17, 2007

I need to use mssql to create a ranking of some kind. This is the situation:
I need to assign position to a list of students based on thier scores. e.g
Student Score Position
StudentA 56 4
StudentB 78 1
StudentC 66 2
StudentD 56 4

I need to create the positions based on the scores of the ctudents.
I will appreciate any assistance.
Thank you.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved