Viewing 15 posts - 5,386 through 5,400 (of 13,460 total)
here's two examples of getting monday or friday of the current week.
--Monday of the Current Week
select DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)
--Friday of the Current Week
select dateadd(dd,4,DATEADD(wk, DATEDIFF(wk,0,getdate()), 0))
from there. you can modify...
Lowell
June 14, 2012 at 10:55 am
easy peasy:
CREATE SYNONYM MailView FOR msdb.dbo.sysmail_allitems
select * from MailView
* note a synonym must point to an object.
so you cannot try to make it part of a name, like getting...
Lowell
June 14, 2012 at 9:39 am
table alias meaning synonym? or table alias in the middle of a SQL statement?
Lowell
June 14, 2012 at 9:33 am
here's my other proc: note that it "toggles" the setting from single user to multi user for multiple calls;
that way if i need exclusive access, i can get it do...
Lowell
June 14, 2012 at 9:31 am
SQLKnowItAll (6/14/2012)
Lowell, in what cases do you use this? For the operation of restoring a database, I would prefer to use the
ALTER DATABASE DatabseName
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO because of...
Lowell
June 14, 2012 at 9:17 am
can you give us the CREATE TABLE definition of dbo.ExRates and a few sample rows?
i suspect you could do this with a pivot, but i'd have to see the table...
Lowell
June 14, 2012 at 9:05 am
here's something i use a lot;
it's just a proc that cursors thru all the spids for a given database name;
sp_kill SandBox would kill all spids attached to the database, except...
Lowell
June 14, 2012 at 8:57 am
farax_x (6/13/2012)
...a customer who has more score has greater chance to win.
you'd have to explain the rules. for example, if i have a "score" of 5, do i have 5...
Lowell
June 14, 2012 at 5:44 am
well, sql express does not allow remote connections by default...did you explicitly change that?
can you connect to that server via SSMS from a machine that is not the server itself?

your...
Lowell
June 13, 2012 at 12:47 pm
yes that is correct; because i'm using a specific delimiter, no format file is needed.
format files are useful when you have stuff like fixed width files or quote delimited...
Lowell
June 13, 2012 at 12:28 pm
i use a special delimiter that I know will not exist in theactual data;
here's my classic example,w hich i use to export html a lot...that always contains a ton of...
Lowell
June 13, 2012 at 12:05 pm
Using SELECT TOP ....ORDER BY NEWID() is probably the most popular way to get randomized results
SELECT TOP 5 *
FROM dbo.tblLottery
ORDER BY NEWID()
Lowell
June 13, 2012 at 11:58 am
a neat trick with the PARSENAME function, which is used to chop up object names like ServerName.DatabaseName.SchemaName.ObjectName:
--Results:
/*
ServerName Instance
----------- --------
MyServer SQL2005
*/
SELECT
PARSENAME(Replace(instancename,'\','.'),2) AS ServerName,
PARSENAME(Replace(instancename,'\','.'),1) AS Instance
from(SELECT 'MyServer\SQL2005' AS...
Lowell
June 13, 2012 at 11:55 am
I'm not familiar with the inner workings of the extended proc xp_logininfo, but it does query the domain controller for the groups a user belongs to, or the users that...
Lowell
June 13, 2012 at 9:45 am
another possibility, but where you would have to grant execute permissions to Everyone ON xp_logininfo (or the trigger has to Execute AS a power user's context) so they can...
Lowell
June 13, 2012 at 5:32 am
Viewing 15 posts - 5,386 through 5,400 (of 13,460 total)