|
First result for accountnumber 1234
SELECT OD.ProductCode, O.DeliveryDate, CASE WHEN O.DeliveryDate IS NULL THEN NULL ELSE OD.Quantity END AS quantity<br />
FROM dbo.Products P INNER JOIN<br />
dbo.OrderDetails OD ON P.ProductCode = OD.ProductCode LEFT OUTER JOIN<br />
dbo.Orders O ON OD.ID = O.ID AND O.AccountNumber = 1234
Second result for accountnumber 6789
<br />
SELECT OD.ProductCode, O.DeliveryDate, CASE WHEN O.DeliveryDate IS NULL THEN NULL ELSE OD.Quantity END AS quantity<br />
FROM dbo.Products P INNER JOIN<br />
dbo.OrderDetails OD ON P.ProductCode = OD.ProductCode LEFT OUTER JOIN<br />
dbo.Orders O ON OD.ID = O.ID AND O.AccountNumber = 6789
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
Hi to all,
Hope I'm posting this in the right discussion group.
I wonder if anyone can tell me if VS 2008 brought in support for rich text formatting or HTML in reports of Reporting Services?
I did see some reports on the possibility but would like to know for sure.
Hope you can help.
Kind regards
Andries
|
|
|
|
|
hi all,
we know getdate() function returns current date. I want get the current time.
Can any one help me...
Thanks in Advance
Senthil S
Senthil.S
Software Engineer
|
|
|
|
|
SELECT RIGHT(CONVERT(varchar(23), GETDATE(), 8),11)
|
|
|
|
|
select convert(varchar(15),getdate(),108)
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
i have a column its values must started with 1 and incrementing by 1
this column repeatly looses his rows
so i can not use identity here
so i tried to raise a trigger to do the job
but i have some probelems with the following statments
create trigger dbo.insertNum
on testIcreTrigger --table name
for insert
AS
begin
declare @insVal int --value to insert
declare @MaxVal int
select @MaxVal= Max(Num) from hitTheatre
select @insVal=@MaxVal+1
insert into testIcreTrigger (Num)
values (@insVal)
End
Go
|
|
|
|
|
Have you tried
SET @MaxVal= (select Max(Num) from hitTheatre)
SET @insVal= (@MaxVal+1)
Just guessing..
|
|
|
|
|
Another solution is to run DBCC CHECKIDENT('[table name]', RESEED, 0) when you flush the table and just use an identity.
|
|
|
|
|
You should replace *for insert * with *INSTEAD OF INSERT *.
When FOR is the only keyword specified, AFTER is used by default.
CREATE TRIGGER dbo.insertNum
ON testIcreTrigger
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO testIcreTrigger (Num)
SELECT MAX(Num)+1 FROM hitTheatre
END
|
|
|
|
|
Quick question... i'm feeling a bit thick today...
Does...
Begin Tran
stored procedure 1
stored procedure 2
stored procedure 3
rollback
...work? ie are the contents of stored procedures also rolled back?
|
|
|
|
|
|
|
Hello All,
Please help me..
using admin login report showing records.
but i m Unable to view SQL Report normal login
is there any solution...
Thanks,
Ankur Bakliwal
|
|
|
|
|
Hai all,
Can i install sqlserver2000 and 2005 in same folder.
I have already installed sqlserver2000 in my XP,and i want to install sqlserver2005.
I dont if it raises any problem or not,if not,wat kind of things i have to consider.
Give me some answer.
can i install in different folders.my sqlserver2000 and vs2003 are installed in C:/
and vs2005 in D:/,now where i have to install my sqlserver2005.
kissy
|
|
|
|
|
Hi,
I am not sure whether SQLServer 2000 and SQLServer 2005 can be installed in same folder. But they can be installed on same machine in different folders. However, you can not have two default instances of any version of SQL Server but you can have ten different installations of SQLServer 2000 and SQLServer 2005 as long as they are all named differently, they can co-exist with out an issue.
Hope this helps.
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hello All,
Am creating a small Projects using Vb.Net and Sql server 2005, in that i want to get a input automatically for one column(Eno column), that column is a alphanumeric column, i want to store information automatically like below,
if the Employeename is 'Anton' it will automatically fill the Eno as A001, if Employeename is 'Brail' then it will fill 'Boo1' if again Employeename is 'Berg' then 'b002' and so on. can i get that by adding a trigger or stored Procedure, if so then tell simply code examle for this, this very urgent for me, so Pleeeeeeeeeeeeease help me.
Thanks
Riz
|
|
|
|
|
I am going to assume you are trying to create a key field for your employee, if so then:
DO NOT ADD INTELLIGENCE TO A PRIMARY ID/KEY FIELD, you are doing this by adding the first character of the surname. This is wrong, it should simply be the record identifier, use the surname field for search/sorting NOT the ID field.
Generating an employee number for human consumption (timecards or something) is a different matter. I would put it in the inserting stored procedure (I never use triggers)
Before the insert get the count of existing surnames with the 1st char
Select @N = (count(*) + 1) From Employee where Surname like 'A%' (this fails when the employee changes surnames - gets married and is the reason for the initial comment)
or
Select top 1 employee where ENO like 'A%'
order by ENO desc
Add the text to the ENO field
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thank you somuch for your speedy reply. i will try the code and let you know the result, once again i thank you.
Thanks
RIZ
|
|
|
|
|
Hello All,
Below Code generates Error in if, Please let me know whats wrong in this
create procedure refno_stock
as
begin
declare @stockrefno as varchar(50),
@category as varchar(50)
if @category = 'Desktop'
begin
select ( count(*)+1) as Stockrefno from stockmaster where category like'd%';
end if
if @category = 'Laptop'
begin
select ( count(*)+1) as Stockrefno from stockmaster where category like'L%';
end if
if @category = 'HDD'
begin
select ( count(*)+1) as Stockrefno from stockmaster where category like'H%';
end if
|
|
|
|
|
you use END instead of END IF
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Again It shows error in Last End
ie Incorrect sysntax near END, Line 17
|
|
|
|
|
Hi,
I need to creat a trigger on 'myTable' after 'insert' new records...I need to send an email every 30 minutes if Insert happenned...Any one plz can help???
I searched over the Internet, but nothing is useful for this purpose.
And in the future, my goal is to send this email depending on the time specified by the user after Insert.
Kind Regards
OBarahmeh
|
|
|
|
|
This is not a "trigger" or an procedure operation. You would need to create and schedule a job in SQL Server to acheive this. It would have to poll the target table to identify the records inserted say every 2 minutes and if there are records then execute the mailing stored proc.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Dear Holmes,
I am not proffessional in SQL Server...can you please tell me how to do that (create and schedule a job) that send email when insert happens on MyTable???
Thanks
Kind Regards
OBarahmeh
|
|
|
|
|
Hi, I'm still a beginner in this. Creating code in vb to log in a user. The username and password typed into the textbox must be verified against the username and password in the database. I use a SqldataReader to perform this action but can't seem to get the syntax correct... please can you help me.
Here is the Function and the relevant button :
Protected Sub butLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles butLogin.Click
If CheckPassword(txtusername.Text, txtpassword.Text) Then
'FormsAuthentication.RedirectFromLoginPage(txtusername.Text, True)
Response.Redirect("Default.aspx")
Else
MsgBox("username or password not found. try again")
End If
End Sub
Private Function CheckPassword(ByVal username As String, ByVal password As String) As Boolean
Dim bsuccess As Boolean
Dim command As New SqlCommand("SELECT (Username,Password) from UserInfo WHERE Username = '" & txtusername.Text & "'", connection)
Try
Dim drdUsers As SqlDataReader
drdUsers = command.ExecuteReader
connection.Open()
While drdUsers.Read
If txtpassword.Text = drdUsers.Item("Password") Then bsuccess = True
End While
connection.Close()
Catch
bsuccess = False
connection.Close()
End Try
Return bsuccess
End Function
|
|
|
|