If I have a variable that is of the type text or ntext and I want to find out what keywords from a column in a table exist in this document, what is the most efficient way to do this. Also, if a C# program is going to pass me this information, is using a text or next variable more efficient than a table variable where each row represents...
I am using a subquery to return a count as an integer value to my main query. This query is used to rebind an ASP.NET DataGrid and I have only two characters width available for this column. I want to restrict the width to two characters. So, I want to set a value of 99 when the count exceeds 99. I can't figure a way to do this? I c...
What is the most efficient paging solution using SQL Server 2005 against a table with around 5,000-10,000 rows? I've seen several out there but nothing comparing them.
...
I'm trying to do an SQL update where I want to set the value of the column being updated depending on the value in a second table. The script below shows what I'm trying to do but so far I haven't hit on the correct syntax.
update sometable set name =
case
when (select newid from lookuptable where oldid = name) <> null then newid...
I have the following tables for a competition:
User:
Id
Name
Email
EntryId
Entry:
Id
Age
Gender
State
GameResult:
Id
EntryId
Duration
Score
QuestionResult:
Id
EntryId
Correct
UsersAnswer
Each entry will have multiple games, and multiple questions. I need to perform a query that will find a list of the highest scores, and...
Hi,
I have a T-SQL stored procedure where I want to search for a particular value and optionally limit the search to particular dates if they are passed in. If null values are passed in for either of these dates, then I want to ignore those. The way I am thinking of doing this by setting the input dates to minimum or maximum if they are...
hi, I have that query:
with tmp_rows as
(
select * from [dbo].[customer]
)
select * from tmp_rows;
select count(*) from tmp_rows;
I can't get the count of the tmp_rows because I get the error: Invalid object name 'tmp_rows'
If I comment the "select *" query everything is OK
I need to select all rows and then get their count, h...
Suppose i have two tables
declare @emp table
(
EmpID int,
EmpName varchar(10)
)
declare @Remu table
(
EmpID int,
Sal Decimal(10,2),
PaidYear varchar(10)
)
I want maximum salary grouped on PaidYear (With Ties)
Expected OUTPUT
EmpID EmpName PaidYear Sal
1 Jon 2001 2000
2 Smith 2001 2000
3 Na...
I'm generating T-SQL SELECT statements for tables for which I have no data type information up-front. In these statements, I need to perform string manipulation operations that depend on the length of the original value of the tables' columns.
One example (but not the only one) is to insert some text at a specific position in a string, ...
Is there a query in SQL Server 2008 which will delete data from all dependent tables as well, along with the selected table?
My apologies for not having elaborated on the question. I know that Cascade Delete would work fine, but my application connects to a 3rd party SQL Server db. I have a few Unit Tests which insert into the target ta...
what is sqlserver T-SQL equivalent to oracles "show all" listing the set parms on the DB?
...
I need help writing select statement that will do an average of the most recent 52 rows of data.
If there is less then 52 rows it will only do the avg of how many rows there are.
I know the avg function in SQL will skip the null...but i got this far.
SELECT AVG(E.Interest)
from InterestRates E
Where Interest in (select COUNT(Interest)...
I'm using SQL2008 and .NET 4.
The following UPDATE query causes timeout errors.
Table Pages has 600,000 records.
Error:
System.Data.SqlClient.SqlException
(0x80131904): Timeout expired. The
timeout period elapsed prior to
completion of the operation or the
server is not responding.
Query:
UPDATE Pages
SET Checked = 1...
In sql server 2005, the autogrowth is enabled by size.
Is there any way to check when autogrowth on data and log file happened last?
...
When two tables are given
Employee Table
EmpID Name
1 Jon
2 Smith
3 Dana
4 Nancy
Lab Table
EmpID StartTime EndTime Date LabID
1 10:00 AM 12:15 PM 01/JAN/2000 Lab I
1 11:00 AM 14:15 PM 01/JAN/2000 Lab II
1 16:30 PM 18:30 PM 01/JAN/2000 Lab I
...
Hi, I need fast answer (I can't check that code right now):
is that query works ? I need to get the total sum of a column values from the subquery, something like that:
select sum(select time from table) as sometimes group by sometimes
...
I am querying a database with records of meeting room reservations. Since we are a global company we have meeting reservations that span different months, example:
StartTime ........................ EndTime........................ MeetingName
06/30/2010 11:45PM ........ 07/01/2010 01:00AM ..... My Meeting
I...
Hello, I have added Full Text Search to my sql server 2008 express database and created an index catalog for two columns in a single table. So now, I have to rewrite one of my stored procedures but I have no idea where to begin. The following is my current SP that I need to convert to take advantage of the full text search capability:
A...
I have a situation where I have to dynamically create my SQL strings and I'm trying to use paramaters and sp_executesql where possible so I can reuse query plans. In doing lots of reading online and personal experience I have found "NOT IN"s and "INNER/LEFT JOIN"s to be slow performers and expensive when the base (left-most) table is lar...
I have the table in SQL Server 2008. It has empId, which is the int of type. It is not identity for now. I want to write the query (so that I can maintain the record of changes in DB) to make this columns as identity column. This table have no data currently.
...