sql-server

SQL Server Insert Query help

I have the following code that I use in a Query to update a table called ListClientCasePresentingIncidents which uses a function called fnSplit to split a comma seperated nvarchar named @CasePresentingIncidents. IF ( @CasePresentingIncidents <> '' ) INSERT INTO ListClientCasePresentingIncidents ( PresentingIncident ...

how to use sql connection in PHP to execute a query on two databases

how can i run a query that joins two tables from TWO different Databases in mssql_query or mysql_query in php for example $conn=mssql_connect($ip,$username,$password); mssql_select_db("DB1",$conn); $q="select A.name,B.ID from DB1.dbo.T1 A, DB2.dbo.T2 B where A.ID=B.ID"; $res=mssql_query($q); how to run such query?? ...

T-SQL: Question about NOT IN

Why would these queries return difference results: SELECT * FROM ProjectStatus PS WHERE 0 = (SELECT COUNT(*) FROM Project P WHERE P.ProjectStatusKey = PS.ProjectStatusKey) SELECT * FROM ProjectStatus PS WHERE PS.ProjectStatusKey NOT IN (SELECT P.ProjectStatusKey ...

Sending mail or SMS after the query has been executed

Hi, Currently I am dealing with a large dataset and some queries are executing several hours. In the meantime I am doing other things. In order to use time efficiently I have been thinking about implementing the logic to send email or SMS message after the query is complete so I can analyze the data. I know how to do it by writing cust...

How to get words from field in SQL Server 2008

I need to get the words in a text field and make some updates with those words, for example: original data words | other field | another field --------------------------------------------- white | | some words | | some other w | | desired result words | other...

SQL Server running slow due to thread count increase.

On our production server, for some reason at specific amount of time, thread count goes over and over to the certain point that though CPU Utilization is normal(30-50%), but the query starting to run slow we so lot more blocking statements. I am not sure where to look at it, basically when our site runs normally, the thread count is aro...

T-SQL cursor and update

I use a cursor to iterate through quite a big table. For each row I check if value from one column exists in other. If the value exists, I would like to increase value column in that other table. If not, I would like to insert there new row with value set to 1. I check "if exists" by: IF (SELECT COUNT(*) FROM otherTabe WHERE... > 1) ...

declaring temp table in both branches of a sql server stored proc conditional

I want to have a construct in a stored procedure that defines a temporary table one way in one branch of an if-else and another way in the other branch, but this won't compile b/c it says the table is already created. I am imagining something like the following: if begin IF OBJECT_ID(N'tempdb..#tbl') IS NOT NULL DROP TABLE #tbl cr...

How to select rows where multiple joined table values meet selection criteria?

Given the following sample table schema Customer Table CustID 1 2 3 Invoice Table CustID InvoiceID 1 10 1 20 1 30 2 10 2 20 3 10 3 30 The objective is to select all customers who have an InvoiceID value of 10 and 20 (not OR). So, in this example customers w/ CustID=1 and 2 would be return...

Classic ASP Bottlenecks

I have 2 websites connecting to the same instance of MSSQL via classic ASP. Both websites are similar in nature and run similar queries. One website chokes up every once in a while, while the other website is fine. This leads me to believe MSSQL is not the problem, otherwise I would think the bottleneck would occur in both websites simu...

migration from universe database

how can we migrate from u2 to sql server.tell me the sites where i can find the pdf on migration from u2 ...

recycle time reporting service

Hi, by default the recycle time for reporting service is 720 minutes (12 hours). It is the reportserver.config file 720 Now it happens every 2 o'clock. so consequently, it happens twice a day 2 AM and 2 PM. Now the problem is we cannot have it recycled during business hours (2 PM). how do I set this to occur only @ 4 AM? thanks ...

SQL Joining the first, second and third row of joining table

I need to display some columns on the final result which comes from a join. Those columns comes in 3 groups, say: name_1, addr_1, prefecture_1, price_1, name_2, addr_2, prefecture_2, price_2, name_3, addr_3, prefecture_3, price_3 Where these 3 groups comes from a join which should return only 3 records according to a sort key carrier_...

in sql server how to concatenate two strings

see i want to concatenate this rupesh's and malviya so how can i concenate it in sql server 2005 and also i want to know does it support double quotes? ...

No direct access to data row in clustered table - why?

[11] tells: "In a nonclustered index, the leaf level does not contain all the data. In addition to the key values, each index row in the leaf level (the lowest level of the tree) contains a bookmark that tells SQL Server where to find the data row corresponding to the key in the index. A bookmark can take one of two forms. If the...

Add on or tools for SQL Server

Like for .NET we have some special tools/framework/open source like Entity framework, log4net, various open source tools and projects.. Do we have similar kinds of add on's/tools/software for SQL Server [which is free, of course] ? I am a .NET developer and this is my first deep step to sql server, till now I have worked only on SP,View...

Problem with multipart sql identifiers

I've successfully migrated a website running a SQL Server 2005 db to a new server running SQL Server 2008 R2 and everything seems to work fine except 1 thing. 2 different schemas where used when creating the tables (I have no idea why). So you have to call the tables using a multipart identifier like schemaname.tablename except in the w...

What do I miss in understanding the clustered index?

In absence of any index the table rows are accessed through IAM ((Index Allocation Map). Can I directly access a row programmatically using IAM? Does absence of index mean that the only way to read specific row is full table scan reading all table? Why IAM cannot be engaged for more specific direct access? "If the table is a hea...

sql query takes much long time compared to next run

Hi, I'm running a procedure which takes around 1 minute for the first time execution but for the next time it reduces to around 9-10 seconds. And after some time again it takes around 1 minute. My procedure is working with single table which is having 6 non clustered and 1 clustered indexes and unique id column is uniqueidentifier data...

How do I implement Internet accessible system with Delphi?

Hello I am about to start working on a new system which will need to support multiple users and potentially allow the database to be accessed over the Internet. The system will be win32, not web based, the database will just be in an office and accessible anywhere. I am not sure if this is a dangerous approach security wise, am open t...