SQL Query , SQL or Procedural
HIHi i need some help on what the SQL query would be, let's say i have a resultant table like this.
Group
TestID
Result
A
AA
10
A
BB
30
A
CC
20
B
AB
200
B
AC
300
A
DD
50
C
AA
1000
and i need to query by group and re-name every field as its TestID value for that selected group:
Example:if group "A" is selected:
AA
BB
CC
DD
10
30
20
50
if group "B" is selected:
AB
BC
200
300
and so on..
thanks.
Here is a sample for you to play with PIVOT:
SELECT [...
ADO.NET 2.0 - Three-tier application - connection string error
Using ASP.NET 2.0 beta, VS2005 beta 1, W2k3 server with IIS
I try to build a three-tier app structure as followed:
- the store procedure in SQL with a input parameter as Username and retrieve the UserId as output parameter.
- the business logic (class) with connection string defined in web.config (“AppConnectionStringASPNETapp”)
- the presentation aspx file after the user has logged in through login.aspx
I have work out 2 scenarios with 2 different errors.
Scenario 1:
Here is the code is business logic (class) (catalog.cs)
using System;
using System.Data;
usi...
Stored Procedure executing durations are different between executing from application(web) and SQl server management studio
Hi,I have a web application using Stored Procedure (SP). I see that there's a SP taking long time to execute. I try to capture it by Profiler Tool, and find out that with the same SP on the same db with the same parameter. The duration of executing by my web app is far bigger than the duration of executing on SQl server management studio - query windowPlease see the image attached http://kyxao.net/127/ExecutionProblem.png Any ideas for this issue?Thanks a lot Jalijack
through sql management studio you get better perfomance because it directly access to db engine an...
Copy stored procedures from SQL to SQL DE?
Is there an easy way to copy all stored procedures from an SQL server to en SQL Desktop Engine or do I have build all stored procedures by hand?Johan TheunissenMCPD, MCSE, MCTS BizTalk 2006==============================Please mark the most helpful reply/replies as "Answer".
You can use the SQL Server import/export wizard, or you can generate a script of them using SQL Server Management Studio.
Thanx,
In the mean time I copied them manually (copy-paste).
So I think a seperate script would be usefull when you have 100+ stored procedures. Or have the script available.Johan Theu...
Linq to SQL and stored procedure with dynamic sql
I have a stored procedure like create proc test
as
.....
set @sql = 'select ' + .... + ' from ....'
exec(@sql)The select list is dynamically (in fact, pivot table). However, after drag the stored procedure to dbml design view and called, the stored procedure only return an integer.How to get the result set of the stored procedure when using dbml?Thanks,
Is this the only SELECT statement that @sql gets? I created a simple example and it performed as I would expect returning a complete recordset....I'm wondering if your stored proc is returning 2 record se...
sql or my sql query
hi,in my database i have the two tables...1)programs 2)reservedin the programs...two fields 1)program id 2)maxseats................these details wil be entered by adminin the reserved table two fileds ..1)PRogramid 2)statusmy requirement is .. i need the available seats..meansif any body is intersted in any program...they wil select the program...then status becomes approved(1)..then i need the o/p as ...
VB.NET SQL stored procedure: procedure has no parameters and arguments were supplied
VB.NET SQL stored procedure: procedure has no parameters and arguments were supplied
Please assist me:This erorr message is produce when calling the stored procedure in vb.netProcedure AutomateMatterNumber has no parameters and arguments were supplied."MS SQL 2000stored procedure:*/CREATE PROCEDURE dbo.AutomateMatterNumber ASDECLARE @nextMtr AS BIGINTDECLARE @dtToday AS DATETIMEIF NOT EXISTS(SELECT * FROM tempMatter WHERE DATEDIFF(dd,DateSet,GETDATE())=0 )BEGINDELETE FROM tempMatter-- incase there are some old recordsSELECT TOP 1 @nextMtr= CONVERT(BIGINT, MatterNumber) + 1 ,@dtTod...
SQL string into Stored Procedure
Not sure this is the right forum as I'm not sure quite what the problem is, but I have a feeeling it's the stored procedure that I'm using to replace the SQL string I used previously.I have a search form used to find records in a (SQL Server 2005) db. The form has a number of textboxes and corresponding checkboxes. The user types in a value they want to search for (e.g. search for a surname) and then selects the corresponding checkbox to indicate this. Or they can search for both surname and firstname by typing in the values in the correct textboxes and selecting the checkboxes corress...
LINQ in a SQL CLR Stored Procedure (SQL 2008)
Hey all, i'd like to use LINQ in a CLR Stored Procedure in SQL 2008. The problem is, i can't add a reference to System.Xml.Linq. How do i make that happen? my SQL project is targeting .net 3.5, and i have SP1 installed.I saw a blog about this somewhere recently but now i can't find it. so if you can point me to something, that would be awesome.thanks,-b
I googled and found this blog http://oakleafblog.blogspot.com/2007/09/problems-using-stored-procedures-for_08.html
Beware of bugs in the above code; I have only proved it correct, not tried it. (Donald Knuth)
That does...
SQL Stored Procedure Issue
This is the Stored Procedure below ->
SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GO
/****** Object: Stored Procedure dbo.BPI_SearchArchivedBatches Script Date: 5/18/2007 11:28:41 AM ******/if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[BPI_SearchArchivedBatches]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)drop procedure [dbo].[BPI_SearchArchivedBatches]GO
/****** Object: Stored Procedure dbo.BPI_SearchArchivedBatches Script Date: 4/3/2007 4:50:23 PM ******/
/****** Object: Stored Proc...
SQL Stored Procedure to MySQL Stored Procedure Conversion
Hi, I am trying to convert a stored
procedure written for sql to one that will work in mysql. I understand
that I have to set the variables as IN , but I
don't know what to do with the rest of the code. The following is the
sql stored procedure that I am trying to convert to msql stored procedure:
CREATE PROCEDURE Register_User
(@userName Varchar(50),
(@PassWord Varchar(50),
(@FirstName Varchar(50),
(@LastName Varchar(50)
)
AS
IF EXISTS(SELECT u_ID
FROM User_ID
Where u_UserName=@UserName)
RETURN -1
ELSE
INSERT User_ID(
u_User...
cancelling query initiated from web form, WAS 'Cancelling HUGE sql queries'RE:
http://archive.develooper.com/dbi-users@perl.org/msg08566.html
http://archive.develooper.com/dbi-users@perl.org/msg08567.html
It was suggested to capture the PID in order to kill any abandoned queries.
This appears to work if the web server, web app, and database are all on
the same machine.
However, it doesn't seem so if the web server and database are on different
machines.
What we've noticed is that when we kill the web app PID, the database query
process still remains active. Yet, when we directly kill the database
query PID, the web app PID is automagically k...
Stored ProceduresI am trying to create a StoredProcedure (below) that requires more than one
SQL statement to be executed. I am getting a batch error as follows:
Result set not permitted in '<batch statement>'.
I am using ASA9 - version 9.0.1751. The following is the stored procedure
that I am trying to execute.
ALTER PROCEDURE "DBA"."asi_SDSelectUserDetailsRange" (
@lrange varchar(5),
@hrange varchar(5),
@Filter varchar(20),
@ColumnName varchar(20)
)
BEGIN
DECLARE @SQL1 varchar(8000);
DECLARE @SQL2 varchar(8000);
DECLARE @SQL3 varchar(8000);
D...
Can sql queries be nested in sql queries?I am having problems with a template that uses the information from one sql
query to generate a query on another table. Let me be more specific. The
template in question receives a category ID value from a web page that
provides a menu of several categories to choose from. Each Category ID
represents several Items or products to choose from. When the template
receives the category ID, the first thing it does is run a query on my
item_category table (this table lists all of the items and associates them
with the appropriate category). This query returns several itemIDs that are
all...