Use this tag for questions specific to the 2008 version of Microsoft's SQL Server.
2
votes
1answer
48 views
T-SQL USE satetement in condition
It seems that USE statement is compiled by MS SQL Server 2008R2.
For example,
if(1=0)
begin
USE MyDB
end
The result will be in executing USE MyDB while ignoring IF statement.
How can it be ...
1
vote
1answer
16 views
update cascade in self referencing table - best practice?
It seems that it not possible to set an update cascade on a self-referencing table.
As a consequence, it is not possible to simply rename a parent node. The only workaround I can see is to create a ...
0
votes
2answers
37 views
How can I increment the value for each INSERT INTO iteration?
I have a Query as shown below
column1 is int
anothercolumn is varchar(100)
INSERT INTO TABLE1 (column1,column2)
SELECT (MAX(column1) FROM TABLE1)+1 ,anotherColumn FROM TABLE2
Table1 Before Query
...
0
votes
2answers
36 views
Why this CTE expression hangs while temp table runs fine
I have below SQL CTE statement which i found to be a bottleneck for the performance. While debugging, it just hangs there (I think it does table scan) so i replaced it with a temp table and the query ...
-6
votes
1answer
36 views
DISTINCT command in SQL Query [on hold]
There's a STUDENTS table that looks like this:
name number grade
------ -------- -------
sara 2 C
fred 2 D
bob 3 A
What does this query do? :
SELECT name, COUNT ...
4
votes
1answer
40 views
Validate password in stored procedure
I'm having trouble with validating an account in a SQL Server stored procedure. What I do is that I Hashbyte the password of the user. When he wants to log in into his account I again hashbyte the ...
-1
votes
1answer
24 views
Are there any issues using coldfusion and sql server web edition?
Anyone having issues with coldfusion and sql server 2008 web edition?
0
votes
2answers
32 views
From a SUM aggregrate trying to extract only the max value
/* THIS WORKS - Shows yesterday’s hourly sessions for all prod servers */
SELECT
SUM(active_sessions_peak + inactive_sessions_peak)
AS TotalSessions, machine_name, time_stamp
FROM ...
-1
votes
4answers
44 views
Query not working1
Hey all I am trying to select data from three different tables based on the data found. It's not working. I am trying to display the selected in a grid-view. Any ideas?
SELECT BossID, Status, ...
1
vote
1answer
17 views
Display all managers and employees without a manager
I have a table in SQL Server 2008 that for explanation purposes contains, ID, Employee and ManagerID.
eg:
ID Employee ManagerID
1 A NULL
2 B 2
3 C 2
I want to write a ...
0
votes
1answer
35 views
Convert Time - T-SQL
I have 05:00 AM or 5:00 AM or 00:05:00 AM or 00:5:00 AM or 5 AM (hours....but can also have minutes or seco
I want to convert this to HH:MM:SS The above example is in Hours but it could be in minutes ...
0
votes
2answers
29 views
SQL Ranking Dates to Get Year Over Year Order
I have a list of dates in a YYYYMM format and I am trying to rank them in a Year over Year format that would look like the following:
MonthDisplay YearMonth Rank MonthNumber YearNumber
Aug-2013 ...
1
vote
1answer
24 views
Count number of Distinct days in query
We have a table that has a StartDate field which holds a type of datetime. There are thousands of records and I am looking for a way to find the number of days within a given result returned from ...
-1
votes
0answers
19 views
Update Table from the Changes on other Table
For example I have this tables the SQL SERVER 2008R2
CustomerTable
CusID CusName
7001 Kevin Rulloda
7002 Gio Villanueva
7003 Emmanuel Enriquez
OrderTable
OrderID Order CusName
1 ...
0
votes
0answers
11 views
calling multiple sql udf's from a stored proc to look up data
I have a sp that needs to show some lookup values from another table that stores custom field labels and values.
I wrote a couple table valued inline udf's as below:
This one retuns a custom value ...