|
Using a calculation in Order By
col1 col2 col3
5 5 1/1/1970
0 0 1/1/1972
5 5 1/1/1971
0 0 1/1/1973
Select col1, col2, col3, col1 - col2 As col4
From t1
Order By col1 - col2, col3
In the above case, the order is not what I was expecting. It is as if it is
sorting by col1 t ...
Wed, 5 Jan 2005 09:51:03 -0800
|
Using UNION
I need to combine the counts of 3 tables into 1 final value.
I have a query like below
select count(*) as total from table1
union
select count(*) as total from table2
union
select count(*) as total from table3
How do I get the total from this query? I have tried wrapping the above
query in () and se ...
Wed, 5 Jan 2005 09:45:04 -0800
|
How to create a Pivot table like the following
Guys -- I'm having trouble trying to achieve a pivot table output. How to I
format my query to displ ...
Wed, 5 Jan 2005 11:32:20 -0600
|
SQL Server 2000 (64-bit)
Does anyone know when the client tools will be released for the 64-bit
version??? ...
Wed, 5 Jan 2005 09:21:09 -0800
|
Where Clause Syntax Error
I built the WHERE Clause part of the query into a variable called
@LikeString. I am getting a syntax error [Incorrect syntax near the keyword
'ORDER'.] when I use the variable name after the WHERE
SELECT FunctionID, AccessRoles
FROM SubMenus
WHERE @LikeString
ORDER BY MenuOrderLevel
If ...
Wed, 5 Jan 2005 09:09:03 -0800
|
SUB-SELECT Nightmares!
Hi,
Hopefully someone can help... I am writing a large query to return results
for a report. It uses many subselect queries to return data and I am
getting some incredibly spurious results.
I need my counts at 'campaignID' level, and so I initially have a query to
return the unique campaigns, thus:
...
Wed, 5 Jan 2005 17:08:25 -0000
|
Remove commas
Does anyone know of a way I can remove commas from data that is in a table?
Another programmer imported the data into sql server and left commas in one
of the fields. The application does not recognize the comma, so therefore it
errors out. There are about 2500 records that would have to be updated to
remove ...
Wed, 5 Jan 2005 08:59:11 -0800
|
Help! Crosstab Query
I am trying the following SQL statement:
DECLARE @PN varchar(50)
SET @PN = '5501'
SELECT OptDescription,
SUM(CASE PlanNumber WHEN @PN THEN Price ELSE 0 END) AS @PN
FROM EstimProposalBase
GROUP BY OptDescription, PlanNumber
Which uses the following table:
ID PlanNumber Price OptDescription
...
Wed, 5 Jan 2005 10:00:38 -0700
|
"Generate Script" using code
Hi,
Is possible to Generate a script of the database using the SQL Analyzer or
SP?
Could anybody post any examples? I am insterested in specifying some
properties as well, but I don't know
if all this is possible. I haven't been able to find an example yet.
Thanks a lot.
...
Wed, 5 Jan 2005 17:34:42 +0100
|
Removing Leading Zeros
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
...
Wed, 5 Jan 2005 10:58:47 -0500
|
moving data from one field to another
I could do this with ASP, but I cannot find anything in BOL to let me know
how to do this via T-SQL. I created a new field in an existing table, and
I'd like to take the data in field1, move it to field2, row by row, and then
go back and set field1 to NULL for the same rows.
I guess I don't know the proper se ...
Wed, 5 Jan 2005 09:18:18 -0600
|
GetStoredProcedurePermissions(Username)
I want to write a stored procedure that takes a username or role and returns
a table as detailed below:
SPName CanView
-----------------------------
GetXXX True
InsertXXX False
UpdateXXX False
DeleteXXX False
etc... for ALL stored procedures ...
Wed, 5 Jan 2005 10:19:06 -0500
|
Stored procedure dataset name change
In returning a dataset as XML from a stored procedure, the root element is
named "NewDataSet".
How can I specifiy the dataset name in the stored procedure?
Thanks. Tom_B ...
Wed, 5 Jan 2005 06:19:02 -0800
|
Trigger Problem
Sorry, raydan. This solution gives the wrong answer or crashes
when the language or dateformat puts the day before the month,
depending on whether it's run before the 13th of a month or not.
A safe way to use cast..convert is with format 112, which is
language and dateformat independent:
cast(convert(char(8) ...
Wed, 5 Jan 2005 09:17:39 -0500
|
Restoring User Rights?
Hi,
I've deleted and re-added a user to the db. But now this user doesn't have
any rights anymore. Can someone please tell me if there is a stored
procedure or something to re-gain these rights easily?
This is what I did:
USE master
EXEC myDB..sp_revokedbaccess MyAdmin
EXEC sp_droplogin 'MyAdmi ...
Wed, 5 Jan 2005 15:01:15 +0100
|