Showing posts with label books. Show all posts
Showing posts with label books. Show all posts

Wednesday, March 21, 2012

PLZ help: problem with a certain query

I have this easy query , but the MSSQL server give me an error (Incorrect syntax near ',')

my query is:

--

SELECT Book_Name FROM Books

WHERE (Year,Faculty) =

(SELECT Year,Faculty FROM Books

WHERE Book_Id =100);

--

its seems the error because this line: WHERE (Year,Faculty) =

I don't what the problem!! this query is legal in mysql but not in mssql.

when I tried this one:

SELECT Book_Name FROM Books

WHERE Year =

(SELECT Year FROM Books

WHERE Book_Id =100);

--

its succeed ...

why the first not?

please help or give me any advice....

thanks in advance

Use the following query...

SELECT Book_Name FROM Books Join

(SELECT Year,Faculty FROM Books

WHERE Book_Id =100) D on Books.Year = D.Year and Books.Faculty = D.Faculty

|||

that great ..... thanks you.

but what I can do if I want to use "not in" instead of "=":

the new query will be:

--

SELECT Book_Name FROM Books
WHERE (Year,Faculty) not in
(SELECT Year,Faculty FROM Books
WHERE Book_Id =100);

-

|||

use the following query..

SELECT Book_Name FROM Books Left Outer Join

(SELECT Year,Faculty FROM Books

WHERE Book_Id =100) D on Books.Year = D.Year and Books.Faculty = D.Faculty

Where D.Year is NULL or D.Faculty is NULL

-or

SELECT Book_Name FROM Books Where Cast(Year as varchar) + '-' + Cast(Faculty as varchar) NOT IN

(SELECT Cast(Year as varchar) + '-' + Cast(Faculty as varchar) FROM Books

WHERE Book_Id =100)

|||

thank you a lot.

Worked for me

Tuesday, March 20, 2012

plz guide me

i want to know which book is better for sql server programming. (t-sql)
(those books are available in india)hi,
u can refer SQL Programming exam guide from MS Press
or SQL Server in 21 days would be fine
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"varun malhotra" wrote:

> i want to know which book is better for sql server programming. (t-sql)
> (those books are available in india)

Saturday, February 25, 2012

Please help: Shrink SQL Server database

See Books OnLine regarding dbcc shrinkfile and
shrinkdatabase.

>--Original Message--
>Hi,
>I created a database for test purposes. I am trying to
obtain some
>metrics for various scenarios I wish to test. Many of
these scenarios
>involve bulk inserts. Rather then deleting all rows after
each run I
>simply dropped and recreated the tables. However I've
noticed that the
>mdf and log files are getting larger and larger even when
the database
>is completely empty of data. How can I safely shrink the
size of these
>files?
>Thanks,
>Paul
>.
>Thanks