|
|
Hi,
But I have to add those transactions in the stored proc itself only not in the front-end, can u please give me example or link of it.
Thanks a Lot,
Aleem Mohammad.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
Did you read all about transactions 1, 2 and 3. That pretty much demonstrates how it works.
I didn't get any requirements for the signature
|
|
|
|
|
Hi all,
Iam usind sql service reporting tool for generating reports ..
I did some samples in that..I cant undstand the non query and from query options in report parameters tab..please cn any one explain abt tat..
non query option swe can give values which will come in combo box options and we can select any one and generate reports ..how can we make use of from query option..can anyone expalin with example
|
|
|
|
|
From query is simple enough, you just assign a DataSet from the report as the source of the items in the dropdown. Much like populating a dropdown in any UI.
|
|
|
|
|
thnx for ur reply..
I have fileds id,name in table1
I have my Query string = select * from table1 where id=@pid
in the parameters (pid)properties I assigned the value field and labelfield as id
and also in defalult values of from query i gave the label field as id but some error is there
Error 2 [rsInvalidReportParameterDependency] The report parameter ‘code1’ has a DefaultValue or a ValidValue that depends on the report parameter “code1”. Forward dependencies are not valid.
can u tell me wat error i did?
|
|
|
|
|
Hello
w
Could not find stored procedure 'dbo.GetUniqueCombinations4OurNumber'.
Any idea??????
Urgent plz...................
Syed Shahid Hussain
|
|
|
|
|
The SQL engine doesn't accept txt spk 4 its procedure names, thus it needs to be dbo.GetUniqueCombinationsFOROurNumber.
Well known problem, simply solved.
|
|
|
|
|
ok thenks let me check
Syed Shahid Hussain
|
|
|
|
|
Its worked fine
thanks boss
Syed Shahid Hussain
|
|
|
|
|
neilarnold wrote: Well known problem, simply solved.
Oops, I meant to vote this a 5, but it ended up as a 1 because I goofed while not paying attention. Sorry, but just thought you'd wanna know.
|
|
|
|
|
Hi All,
After searching the web for a solution I just seem to be more confused - If someone could throw some light on this I would really appreciate it - as my sql isn't brill as you will see..
I have a sql SP which accepts 2 params:
@SalesOrderID int = 0,
@AllocationEndDate datetime
The select statement contain various joins from orders & allocations tables.
Its the main where clause that I am having issues with - If I pass a SalesOrderID into this SP I want the where to match this ID along with some date checking & a trans type. If I dont pass a SalesOrderID I want the where to just match on the date checking & a trans type.
See below the code which I have & that doesnt work:-
IF @SalesOrderID = 0
Begin
Where
(M.DateTransactionDue >= '01/01/1900' AND M.DateTransactionDue <= @AllocationEndDate) AND M.TransactionTypeID = 1
END
ELSE
Begin
Where
(M.SalesOrderID = @SalesOrderID) AND (M.DateTransactionDue >= '01/01/1900') AND (M.DateTransactionDue <= @AllocationEndDate) AND
(M.TransactionTypeID = 1)
END
I did try a Case statement I couldn't get that to work either:-
--WHERE
--(case @SalesOrderID
--when 0 M.DateTransactionDue >= '01/01/1900' AND M.DateTransactionDue <= @AllocationEndDate AND
-- M.TransactionTypeID = 1
--when > 0 (M.SalesOrderID = @SalesOrderID) AND (M.DateTransactionDue >= '01/01/1900') AND (M.DateTransactionDue <= @AllocationEndDate) AND
-- (M.TransactionTypeID = 1)
-- else -1
-- end)
Many thanks
Janet
Lady Programmers are a rare breed!
|
|
|
|
|
I've come across this situation as well and here is the equivalent of what I've had to do:
WHERE @SalesOrderID = case when @SalesOrderID > 0 then M.SalesOrderID else @SalesOrderID end
AND M.DateTransactionDue BETWEEN '01/01/1900' AND @AllocationEndDate
AND M.TransactionTypeID = 1
In the above, you kind of have to think of the SalesOrderID filter very differently of how we normally handle it. Essentially, we'll use the CASE statement to compare @SalesOrderID either to the Field M.SalesOrderID or to itself. Comparing it to itself is the situation where the value is not provided and we don't want to filter on it, but we have to put something there and that accomplishes it. Also, notice that the CASE statement is resolved to provide the right side of the equals, so this gives you the flexibility to determine what you want to compare against; it's a pretty handy technique. If you prefer not to have the CASE statement and are free to modify the SP, you could have the @SalesOrderID default to NULL and then use ISNULL() in the WHERE, like so:
WHERE ISNULL(@SalesOrderID, M.SalesOrderID) = M.SalesOrderID
AND M.DateTransactionDue BETWEEN '01/01/1900' AND @AllocationEndDate
AND M.TransactionTypeID = 1
In this situation, when @SalesOrderID is NULL, the ISNULL function will use the Field M.SalesOrderID's value for the left side of the equals, essentially toggling whether to compare M.SalesOrderID against @SalesOrderID or itself and mimicking the desired behavior that the condition be optional; this too is also a handy technique. It's more compact and accomplishes the same thing as the above WHERE clause as long as @SalesOrderID defaults to NULL.
Keep It Simple Stupid! (KISS)
|
|
|
|
|
Since C# is my expertise & really appreciate your help with SQL. I now have 2000+ records returned (its only taken most of the aft!).
I used your example for the 'Case' as I couldn't get the ISNULL to work - even though I prefer the look of that syntax as it is easier to read - It kept telling me that '@SalesOrderID: this input parameter cannot be converted. This does have to be defined as an int - so Im assumming the ISNULL cannot be used in this instance, but I will remember for the future.
Thanks again...
Janet
Lady Programmers are a rare breed!
|
|
|
|
|
Hi,
I have a problem using synonyms in stored procedure.
In my procedure I create a synonym based on a specific business logic.
For example:
create procedure test_sp_create_synonyms
as
if object_id('synTest')is not null
drop synonym synTest
exec('create synonym synTest for Counters')
select top 10 * from synTest
go
The problem appears when before executing this procedure, the synonym synTest
points to table T1 that does not exists, and the table T1 is placed on Linked Server.
For example:
synTest -> [test_ls].[DB1].[dbo].[T1]
When I execute the procedure an error is raised:
The OLE DB provider "SQLNCLI" for linked server "test_ls" does not contain the table ""DB1"."dbo"."T1"". The table either does not exist or the current user does not have permissions on that table.
The problem is only when T1 is situated on linked server. If is on a local server(example: synTest -> [dbo].[T1]) here is no problem and the execution of test_sp_create_synonyms passes OK.
I will be grateful if someone can help me.
|
|
|
|
|
This doesn't quite make sense.
The synonym creation should be ok even if the table doesn't exist, but your select statement (select top 10...) should fail if T1 does not exist in target database. But then again, this is supposed to happen if the table does not exist.
Synonyms can be created against non-existing objects and that shouldn't be any problem as long as when using the synonym the object exists.
Or did I miss something?
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Hello all,
I'm wondering how to get the schema of the result set returned by a stored procedure without calling it. I know that some code generation tools do this, but I've been unable to figure out how to go about it. Is there some INFORMATION_SCHEMA view that does this that I don't know about?
Thanks,
Will
|
|
|
|
|
I have the impression they discovery tool actually executes the procedure to get the resultset. The only other way I can think of would be to parse the sysobjects data but that would be a nightmare.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I ran a SQL trace. Looks like this kind of thing is what they are doing. I tested it and it is non-destructive.
SET FMTONLY ON
EXEC Test_Proc
SET FMTONLY OFF
I've never seen that keyword before. Ever day is a learning experience.
|
|
|
|
|
Hi,
I have a problem with attaching databases to Microsoft SQL Server Express 2005, databases are attached as Read-Only even I'm using Management Studio or sp_attach_db stored procedure.
Can you help me??
|
|
|
|
|
One possibility is that the database is marked read-only before detach. If the database isn't in restoring state (everything is fine after attach), could you simply set it to read-write state:
ALTER DATABASE DatabaseName SET READ_WRITE;
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Hi Mika, thanx for reply
I cannot change database to be read write when I tried your code I received the following errors:
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "D:\>> DatabaseName.mdf". Operating system error 5: "5(error not found)".
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file "D:\>> DatabaseName.ldf". Operating system error 5: "5(error not found)".
File activation failure. The physical file name ">> DatabaseName.ldf" may be incorrect.
Msg 945, Level 14, State 2, Line 1
Database 'DatabaseName' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
My database is a valid database copied from another machine on witch it works fine.
|
|
|
|
|
Ahmad Safwat wrote: Database 'DatabaseName' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
In the ALTER command, replace the DatabaseName with the actual database name and try again. Now you tried to set options for database named DatabaseName. For example if your database is named Test then the command would be:
ALTER DATABASE <code>Test </code>SET READ_WRITE;
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
I'm sorry it was the weak end, and I was unable to follow up the thread
Mika Wendelius wrote: replace the DatabaseName with the actual database name
I understood you first time and this is what I exactly did, and received the previous errors.
And my database is a valid database copied from another machine on witch it works fine.
|
|
|
|
|
Ok,
The error message you got when trying to set read_write is quite odd. It clearly states that your physical files are not in good condition or not found.
- are there any suspicious messages in the error log when you attach the database?
- also check that the file attributes are correct on both physical files (not read-only and not system)
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|