I have the following tables:
Orders, Notes, Permits
The following columns are in each table:
Orders = ID
Notes = ID, RelatedID, Note, Timestamp
Permits = ID, OrderId
I have the following query
SELECT o.id
, op.id
, n.timestamp
FROM [tblOrders] o
INNER JOIN [tblNotes] n ON n.[RelatedID] = o.[ID]
INNER JOIN [tblPermits] op...
How does the PRIMARY KEY keyword relate to clustered indexes in SQL Server?
(Some people seem to want to answer this question instead of a different question I asked, so I am giving them a better place to do so.)
...
I'm debugging a stored procedure via SSMS 2008. I have a uniqueidentifier variable that gets assigned from a select statement. I want to change its value while I'm debugging to NULL after the assignment.
I can change the value to a different guid, but I cannot change it null. I've tried changing the value to NULL, 'NULL', (NULL), [NULL]...
I'm using a CONTAINSTABLE query with MS SQL Server's full-text indexing engine to search within a textual column; e.g.:
SELECT *
FROM MyTable
INNER MERGE JOIN CONTAINSTABLE(MyTable, sDescription, 'FORMSOF(INFLECTIONAL, "brains")')
AS TBL1 ON TBL1.[key]=MyTable.ixKey
This does a great job of finding rows with a description includi...
hello all i'm having a bear of a time getting visual studio 2010 (ultimate i think) to properly attach to my database. it was moved from original spot to #MYAPP#/#MYAPP#.Web/App_Data/#MDF_FILE#.mdf. I have three instances of sql server running on this machine. i have tried to replace the old mdf file with my new one and cannot get the...
Hey all, is there any SQL Server 2005 guru that can tell me a type of trick to get the values of what is being queried?
Ex:
UPDATE l SET Inactive = 1
FROM tbl1 e JOIN tbl2 l ON l.CID = e.CID
JOIN tbl3 p ON p.PID = e.PID
JOIN tbl4 c ON c.PID = e.PID
LEFT JOIN tbl5 g ON g.EID = e.ID
AND g.PID = e.PID
WHERE e....
A colleague and I wrote this stored proc that documents a database table in wiki markup, for a ScrewTurn wiki system. Originally, I wrote it without a cursor, because until today I never even knew how to use one!
I started with what is essentially a combination of what you see below. I would select one column for each row, where that co...
I want to do this:
create procedure A as
lock table a
-- do some stuff unrelated to a to prepare to update a
-- update a
unlock table a
return table b
Is something like that possible?
Ultimately I want my SQL server reporting services report to call procedure A, and then only show table a after the procedure has finished....
I would like to filter duplicate rows on conditions so that the rows with minimum modified and maximum active and unique rid and did are picked. self join? or any better approach that would be performance wise better?
Example:
id rid modified active did
1 1 2010-...
This question reminded me of a couple related problems with whole-set comparison. Given:
a collection of sets, and
a probe set
Three questions:
How do you find all sets in collection that match probe, element for element?
How do you find all sets in collection that match a collection of probes, without the use of explicit looping ...
I am fairly new to the more advanced database features, such as functions, but I was curious how you would do this in MSSQL (or if it is possible even):
If I have a table and the structure is something like this:
t_test
USR_VALUE MULTIPLIER TOLERANCE VALUE_OK
100 .8 85 OK
100 .9 ...
Based on the following table
Table_A
ID Rev Description
-----------------------------------
1 1 Some text.
1 2 Some text. Adding more.
1 3 Some text. Ading more & more.
The above will keep adding a new row when user updates the description.
I want to take the row with MAX(Rev) [i.e. the latest description].
To...
Given the following table:
Sequence Tag
----- ----
1 a
2 a
3 a
88 a
100 a
1 b
7 b
88 b
101 b
I would like a query that returns the 4th in each sequence of tags (ordered by Tag, Sequence asc):
Tag 4thInSequence
----- --------
...
When the table's rows are changed, these changed rows are written to XML, and let me know that the table has been changed.
How can I do this?
...
I have a Sql Server 2008 Express database file that's currently being used by an ASP.NET application, and I'm not sure how to query the database without taking the website down.
I'm unable to copy the database files (.mdf and .ldf files) to another directory, since they're in use by the web server. Also, if I attach the databases to an...
hello,
this is a followup question to http://stackoverflow.com/questions/3661641/len-of-varbinary
len(0x0a0b0c0d) returns 4 because len counts bytes. does this behaviour depend on the current server collation? if i chose utf-16 for example, would it return 2? in other words, does len treat its argument as string or does it distinguish ...
Hi,
I'm having table like
empid,empname,cityname,statename,countryname.
how to split this table structure?
Regards
Bharathi
...
We're getting a huge LDF file by using a full recovery mode in a SQL Server DB. so we're planning to shrink the log file.
Is there any performance penalty for using DBCC SHRINKFILE to reduce the database log file size (LDF)?
and what about applying it to the data file (MDF)?
...
Dear ladies and sirs.
Examine the following scenario. There is a table with two columns - DateWithoutMilliseconds and Milliseconds. Together these two columns define the exact timestamp with the milliseconds.
Is it possible to write a single SQL statement (not using stored procedures) which would fetch the row with the minimum timestam...
In the application I develop, the database table having a column of 'image' datatype. Now I want to insert the values into that table directly from my program, which is in VC++ 6.0, using a direct ExecuteQuery() of INSERT(due to performance considerations). The image column is been mapped to the structurre of the following declaration
t...