Hi guys,
I am trying to write a SQL query where I am joining two tables and retrieving a few columns. Once this is done, based on a two fields (source table enum, id in the corresponding source table), I need to retrieve a value matching the id in the source table.
The issue is that I cannot join all the source tables, and want to do ...
I imported data into csv table via .net app, pls help, how can i aInsert into all the tables so that i can query;
student avg score to a question or test
student answers to a question or answer frequency to a question etc
My tables are in this form;
Csv Ans Quest Test Ans_Quest_Test
--------- ------ ...
Within SQL Server 2005, is there a way, with a single statement, to deny delete on rows
in a particular table for all users of the database?
...
For Finding nth highest salary I am using
select salary from
(
select distinct ROW_NUMBER() over (order by salary desc) as rownum,Salary
from Employee
)a
where rownum=2
However if i have same salary like
70000
70000
60000
50000
50000
When executing the query i am getting second highest salary
70000 instead 60000
...
I have to compare a row of one table that is not in another table
TableA
ID
1
2
3
4
NULL
TableB
ID
1
4
When comparing TableA with TableB ,the following o/p (NULL Can be ignored)
ID STATUS
1 FOUND
2 NOT FOUND
3 NOT FOUND
4 FOUND
I tried with
SELECT
case T.ID when isnull(T.ID,0)=0 then 'NOT FOUND'
...
I wrote the following query to obtain a date, remove it's time part and add the time I wanted.
If I run this query without the TOP clause, it works well. But when I add it, it returns the following exception: "Conversion failed when converting date and/or time from character string."
Here is the query:
SELECT TOP 1
CONVERT(DateTime, ...
Hi all,
I have such csv file, fields delimiter is ,. My csv files are very big, and I need to import it to a SQL Server table. The process must be automated, and it is not one time job.
So I use Bulk Insert to insert such csv files. But today I received a csvfile that has such row
1,12312312,HOME ,"House, Gregory",P,NULL,NULL,NULL,...
i am adding parameter by
qry = qry.Replace("{criteria}", "info.abc LIKE '%?val%'");
command not worked if i removed ' ' from the command then it give a error how i can search the table in c#
...
-- find last usage info,
-- how far back this information goes depends on the
-- server/database settings
select --
ss.name as SchemaName, so.name as SprocName
,so.create_date as SprocCreated, so.modify_date as SprocModified
,so.object_id
,stat.last_user_seek,stat.last_user_scan,stat.last_user_lookup,stat.last_user_update
,stat.last_...
In a tsql query, I want to have a calculated field that is the boolean result of a string comparison.
It would look something like this:
select name, (status = 'current') as IsValid
from items
But the query as I have listed is not valid. What is the correct syntax?
...
Update: This is a bug but won't get fixed until the next release of SQL Server due to backward compatibility concerns.
This is following on from this question which I answered but am still puzzled by.
Adding TOP (1) to a query is sufficient to change the result from "Sep 3 2010" to "2010-09-03" (at least on my machine with British se...
Possible Duplicate:
Best Book for a new Database Developer
I'm looking to become an intermediate, eventually advance sql programmer. I'm currently half way between beginner and intermediate. I'd like to book to cover at least beginner to intermediate, or all the way even.
Thanks
Thank you all for your responses, I have chos...
I am trying to implement paging for a View in T-SQL :
with TH_VW_UserFollowing as
(
Select FollowerID,
FollowingID,
FollowingFullName,
FollowingImage,
FollowingUserName,
dbo.GetUserFollowers(FollowingID) AS Followers,
ROW_NUMBER() OVER (order by dbo.GetUserFollowers(FollowingID) DESC...
Suppose I have this data:
Employee Task IsCurrent
-------- ---- ---------
Jeff 1 Yes
Jeff 2 No
Jane 1 No
Jane 2 Yes
Jane 3 No
Jane 4 No
Jake 1 Yes
Employees have some number of tasks, and one of them will be current. The task number indicates an ordering -- t...
Thank you for your help in advance. I am looking for a neat solution for the following update scenario:
I have a table TableA with 5 columns (KeyCol, colA, ColB, ColC, ColD)
I have another table Table2 with 2 columns (KeyCol, AvgCol)
I want to do something like this:
update AvgCol in table2, joining on KeyCol
from this logic:
if...
First of all, thank you very much in advance for any attempt at helping me with this. My current query (below) works the way i want it to save the requirement mentioned in the title: I need to retrieve the SUM's of the money columns in my 'expenses' table AND each of these values must correspond to a period_ending value that is greater t...
Hi there. I want to know if I can create an Identity (auto increment on a Varchar column. and how can I make it a primary key and create foreign key references on other table.
This is the code i have -
CREATE TABLE Questions(
QuestionID int IDENTITY PRIMARY KEY,
QuestionNo as 'Q'+Cast(QuestionID as Varchar(10),
Que...
Why the error does not appear at the UI layer? I am using ExecuteScaler
BEGIN CATCH
PRINT N'The transaction is in an uncommittable state. Rolling back transaction.'
ROLLBACK TRANSACTION;
DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;
SELECT @ErrorMessage = ERROR_MESSAGE(),
...
Hi guys,
I am going to implement search capabilities and Email messaging to my website.
Any tips and tricks / Guidenance that I can use to implement these features ?
I am using .NET.
Thanks.
...
I am looking to for suggestions and commments about the following design. All the tables are expected to be large tables (millions of records) and are updated and queried often and any kind of update is allowed (update, insert, delete).
-- product
create table Product(
productID int not null identity(1,1),
name varchar(100) not null,
...