Viewing 15 posts - 5,386 through 5,400 (of 13,465 total)
i would probably tackle it with a scheduled job, or in a service broker fired on database restore or database creation.
it depends on what exactly you are trying to do,...
June 14, 2012 at 12:27 pm
you can use a case statement to return a specific column value based ont heparameter passed:
/*
--Results
2.3
1.79
*/
SELECT [dbo].[ExRateProc]('USD',GETDATE()) As Results
SELECT [dbo].[ExRateProc]('oops',GETDATE()) As Results
CREATE TABLE [dbo].[ExRates](
[ID] [int] IDENTITY(1,1) NOT NULL,
[ratedate] [date] NULL,
[USD]...
June 14, 2012 at 11:03 am
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...
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...
June 14, 2012 at 9:39 am
table alias meaning synonym? or table alias in the middle of a SQL statement?
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...
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...
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...
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...
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...
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...
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...
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...
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()
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...
June 13, 2012 at 11:55 am
Viewing 15 posts - 5,386 through 5,400 (of 13,465 total)