|
Hi,
Thanks sir.I got It.
Veeresh
i want to join this group
|
|
|
|
|
Hi Sir,
Once again iam getting this error.Iam very new to Sql .Can please tel me
how to use single quotes in query.Also giv me some help to this query
Alter procedure LogProc
(
@UserId varchar(500),
@Password varchar(500)
)
as
declare @str1 varchar(500)
declare @str2 varchar(500)
set @str1 = ' select AstId from UserTable where UserId = ''' + @UserId + ''' and Password = ''' + @Password + ''''
exec (@str1);
set @str2=' select RoleId from AstProf where AstId = ' + @str1
exec(@str2);
exec LogProc 'veeresh','veeresh'
Iam getting this error
(1 row(s) affected)
Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'select'.
i want to join this group
|
|
|
|
|
Try the query within a bracket ()
while assigning it with set keyword.
i am not sure try it.
|
|
|
|
|
veereshIndia wrote: set @str='select AstId from UserTable where UserId='+@UserId+'and
Password='+@Password
exec (@str);
You can eliminate 'Set' and 'exec (@str)' statements by having the select query alone which will get the records of the appropriate user.
select AstID from userTable where userid = @userid and password = @password
|
|
|
|
|
I am trying to run a bulk update on a table by picking up the IDs that I've populated onto a table variable based on some criteria.
The update just works fine if the number of records in the table variable are < = 1000.
When this number increases to 5000, the update does'nt work. When I try to debug my code, I get the message box stating "Error while executing 'A Batch Cmd' at line 0; Sql Error: 0 "The statement has been terminated."
On catching this execption I get the message "Timeout expired.The Timeout period elasped prior to completion of the operation of the operation or the server is not responding.\r\n The statement has been terminated."
When I try to run the stored proc from the query analyzer, it keeps processing for a long time and that I've to manually stop the execution.
On trying to run the queries that I have in the stored proc individually did'nt yield me positive results either.
I've ensured that my stored proc meets the specifications listed here[^]
Can anyone throw some light on what can be tried to fix this?
Environment: VS 2005 Pro, Sql Server 2000
|
|
|
|
|
Can you post some of the code up here so we can take a look?
|
|
|
|
|
andyharman wrote: Can you post some of the code up here
Yes,sure. The following lists the logic and flow of my proc.
.... Proc declarations go here ....
Begin Transaction
Declare @tblCategory Table (CategoryID BigInt)
Insert into @tblCategory(CategoryID)
Select A.CategoryID from Shop A Where ProductName = @pProdName
If exists(select categoryId from @tblCategory)
begin
Declare @tblLocalities Table(CategoryID BigInt, LocalityID int)
Insert into @tblLocalities (categoryid,localityid)
select B.CategoryID, B.localityId from ShopGroup B, Shop A
where A.CategoryID = B.CategoryID and A.ProductName = @pProdName
If @@rowcount > 0
begin
Update Shop Set Ranking = 2 where categoryID in
(select t.CategoryID from @tblLocalities t)
end
end
If @@error > 0
Begin
rollback transaction
end
else
begin
commmit transaction
end
|
|
|
|
|
I'm trying to understand what your code is trying to achieve. As far as I can work out, the following would do the same:
UPDATE Shop SET Ranking = 2
WHERE CategoryID in (
SELECT B.CategoryID
FROM Shop A
INNER JOIN ShopGroup B
ON A.CategoryID = B.CategoryID
WHERE A.ProductName = @pProdName
)
Is this any faster? How many rows does it update? What is the purpose of linking to "ShopGroup"?
The next step would probably to look at the indexes.
Regards
Andy
|
|
|
|
|
Yes, inserting or updating a lot of records will take a lot of time, particularly if running other queries concurrently against the same records (which may temporarily block your updates due to locks). ADO.NET stops your application from being blocked forever by imposing a configurable command timeout, which you set in the SqlCommand's CommandTimeout property. It defaults to 30 seconds, so if your command takes more than 30 seconds to execute you get a SqlException.
Management Studio assumes you're more interested in the results than in a speedy response and doesn't time out.
DoEvents : Generating unexpected recursion since 1991
|
|
|
|
|
Mike Dimmick wrote: Yes, inserting or updating a lot of records will take a lot of time, particularly if running other queries concurrently against the same records
Thanks on your views Mike. I will now need to figure out a way to fine tune my proc.
Mike Dimmick wrote: Management Studio assumes you're more interested in the results than in a speedy response and doesn't time out
Do we have any settings / system procs that will take care of the time-out issue in Sql Server 2000?
|
|
|
|
|
Hi All
Background
----------
I have a database table namely tblSection that stores sections that have parent child relationships e.g.
Section 1
|
|--Section 2
|
|--Section 3
| |
| |--Section 4
|
|--Section 5
|
Section 6
The column structure for this table is:
SectionGUID uniqueidentifier PK
ParentGUID uniqueidentifier ALLOW NULL
Title nvarchar(100)
So my root level records are anything where ParentGUID IS NULL and the remaining records can have variable levels of nested children.
My Problem
----------
So what would people suggest with regards handling this structure within SQL for example a typical request is to return all sections below a specific node within the hierarchy? Currently I deal with the scenarios I have by extracting all folders into a single System.Data.DataTable object and then traverse the tree within my code which is OK for certain types of process but now I am looking at more number crunching type processes that approach is slow and cumbersome
Thanks in advance
Andy
|
|
|
|
|
In SQL Server 2005, you can use Common Table Expressions[^] to perform recursive operations.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
|
hi,
in my database i have the two tables...
1)programs 2)reserved
in the programs...two fields 1)program id 2)maxseats................these details wil be entered by admin
in the reserved table two fileds ..1)PRogramid 2)status
my requirement is .. i need the available seats..means
if any body is intersted in any program...they wil select the program...then status becomes approved(1)..
then i need the o/p as available seats ..means if any body selects the program...then the maxseats should be decremented by 1...o/p should be the remaing seats..
|
|
|
|
|
I sincerely hope that you are not asking for code. Let us know what you've tried and where is that you got stuck with.
beklo.com/rameshgoudd wrote: Subject:Re: sql,query very urgent
I am afraid that you are going to be taken in for a chance.
|
|
|
|
|
hi,
'
i need to count how many seats are filled up ..and how many seats are there at to be filled..
i am unable to write the query for this yyar
|
|
|
|
|
What prevents you from using a simple count(*) on the table with the where clause querying an appropriate approved status value?
Have you tried it first?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
beklo.com/rameshgoudd wrote: very urgent
Please desist from using such words like 'Urgent' or 'Please help'. Read this first:
http://www.codeproject.com/scrapbook/forumguidelines.asp[^]
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
I took a screenshot of my select statement source code via mysql, I need to know how to exit this prompt and get back to the regular ( mysql> ) prompt. For some reason the sql statement did not run, and i am stuck in some secondary type prompt.
I posted this question a week ago, and the suggestions were to use a semicolon, well that is quite obvious and one of the first things i did, no-go.
or the following link will take you to screenshot.
SS
|
|
|
|
|
Did you try "go" without the quotes?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
One of your quotes is the wrong way round ("` " should be "' ").
|
|
|
|
|
Im trying to load a Crystal Report I've made in Visual Studio to a Crystal Report Viewer on my form. I used the "database expert" to add the connection (ODBC RDO) to my Access 2007 database. The database has no password on it. The Visual Studio field explorer detects all the fields correctly from my command ( SELECT * FROM Table1; ) so I know it can connect to the databse.
The problem is when I run the program I get prompted for the Logon ID and Password with "Logon Failed. Please Try Again." every time I type something in (or dont type anything in). Again there is no password on this DB. There is no reason this prompt to appear since there is no need for logon info to make this connection.
All of my code VB (this is a test project)
Imports CrystalDecisions.CrystalReports.Engine
Form Load:
Dim crpt As New ReportDocument()
Dim rPath As String = "C:\CrystalReport1.rpt"
crpt.Load(rPath)
CrystalReportViewer1.ReportSource = crpt
Does anyone know how to prevent the Login ID and password prompt from being displayed for the connection?
All suggerstions are greatly appreciated
-- modified at 18:07 Thursday 29th November, 2007
|
|
|
|
|
Is there something buried in the CrystalReport1.rpt file that is wanting you to log in?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
This is a simple test program I made becuase I was having the same issue with a project Im working on. I decided to make this test program to rule out some causes of this connection failure. The only thing this report does is display the two columns from my Access 07 databse.
|
|
|
|
|
I wish I could help you out further, but only thing I can think of is that it must be something on the Crystal Reports end. It's been a fair while since I've tackled CR, so my apologies
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|