My company needs to write a query that determines when data is being entered inaccurately. We have a table in our db called "ProductChanges". It looks (something) like this -
Product User ChangeDate OldValue NewValue
2344 John 24/01/10 10:00 2344 4324
6435 Greg 28/01/10 13:30 ...
Scenario
I have a stored procedure written in T-Sql that I use to insert data into a table as XML.
Since the data gets updated regularly, I want the rows to be updated if they already exist (Aside from when the application is first run, they will always exist).
Question
Below is the code of my Insert Sproc, however I cannot seem to wo...
I have a table with 200,000 records. I want delete some data like below :
DELETE FROM Table Where IdColumn IN ( SelectedID )
SelectedID fill with my desirable data identities that contains 5000 records. there are 2 approach:
1- I insert 20,000 identity as SelectedID that contains identities of desired 5000 records.
2- I insert only ...
Can I Select * into a Sqlserver Table from a SqlExpress Table the way I can from a Sqlserver Table to a Sqlserver Table using
Select * into Table2 from Table1
If so, what is the syntax?
...
Here is an example of the data set I am working with. I am trying to write a query that will allow me to request a row from the items table, and display the User Name from the users table in place of the user ids:
Table 1 - users table
User ID | User Name
--------------------
12 | Fred
13 | Ted
14 | Ned
Table 2 - items...
In oracle, you can issue:
create table foo as select * from bar;
What is the equivalent T-SQL statement?
...
How do I output a table to a txt file using tsql? I don't want to use DTS or SSIS in this instance.
...
I'm looking for a way to non-destructively alter data. I have one table that has data that shouldn't be edited - it is the master data. I would like to have user edits on this data, but in order to maintain the integrity of the master data I've created a second table that is a mirror of the structure of the master table.
My thinking i...
If I have a table as follows:
ID | Name | Category | Parent | URL | LastModified
If two rows have the same Name and parent, then they are not unique. How do I get the unique set of rows in this case (but return more than the columns that make them unique)?
So, for more details:
This is a corporate keywords table, where keywords are o...
Prob an easy question, but I am new to forming XML in SQL 2005, but What would be the best FOR XML SQL statement to use to form the XML seen below from a table that looks like this?
Column1 Column2
------------------------
Baseball Football
Cricket Polo
Swim Beach
Desired XML output:
<Category Nam...
I'm using ADO .NET and MS SQL Server 2008.
I have a connection object to a server and a command:
SqlConnection conn = /* my connection*/;
string cmd = "some_sql_command";
I want to check if SQL Server can execute cmd. I don't want to execute cmd, but I want to know If SQL Server can execute it.
cmd can be any single SQL statement, i...
I need to get top 1 record from same customer inserted within one hour. If record is inserted after one hour then don't need that one.
Please see following table. This is just a sample of 1000s of records. I am using SQL Server 2005.
...
Can UDFs be used inside index views or does this break the SCHEMABINDING logic?
For example if in the where clause of the view I had something like this
WHERE
UserCanSeePost(UserId,PostId)
This UDF would then do a lookup on another table to check some restrictions. I'm guessing this cant be done in indexed views?
...
I'm new to the stop list functionality in SQL 2008 and seem to be missing something obvious. I'm trying to exectue the following statement:
CREATE FULLTEXT STOPLIST myStoplist3
FROM SYSTEM STOPLIST;
GO
and I'm getting the following error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'STOPLIST'.
Any ideas? ...
All,
SQL 2005 sp3, database is about 70gb in size. Once in a while when I reindex all of my indexes in all of my tables, the front end seems to freeze up or run very slowly. These are queries coming from the front end, not stored procedures in sql server. The front end is using JTDS JDBC connection to access the SQL Server. If we stop a...
This seems pretty trivial, but it is now frustrating me.
I am using C# with SQL Server 2005 Express.
I am using the following code. I want to check if a database exists before creating it. However, the integer returned is -1 and this is how MSDN defines what ExecuteNonQuery() will return as well. Right now, the database does exist but ...
How to Fire a trigger when you do TRUNCATE (instead deleted) in MSSQL
...
This is a general question that keeps coming to my mind. Is there any major disadvantage in using the SQL Server 2000 system tables in SQL Server 2008? It is a good practice to use system views, but in simple words, Why?
...
I have query like this
SELECT AVAILABILITY_DATE_TIME FROM APPT_PROVIDER_AVAILABILITY
WHERE AVAILABILITY_DATE_TIME between @START_DATE AND @END_DATE
suppose i have
if @startdate = '2/11/2010 11:31:00 AM' and @enddate = '2/11/2010 11:56:00 AM'
then difference is zero its ignoring time part .
If you can provide query ...
I have a table in SQL Server with these records :
ID Date Time
-- --------- ----
1 09/05/02 6:00
2 09/05/02 8:00
3 09/05/03 6:00
4 09/05/04 8:00
5 09/05/04 6:00
I would like to select those ID who have records in a day which are repeated twice or multiple of two.
How wo...