Forum Replies Created

Viewing 15 posts - 5,386 through 5,400 (of 13,465 total)

  • RE: Looking for Software to automate provisioning of sql logins

    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,...

  • RE: How can I return value from function that comes from dynamic sql

    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]...

  • RE: Using datediff/dateadd function

    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...

  • RE: Programmatically creating a table alias

    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...

  • RE: Programmatically creating a table alias

    table alias meaning synonym? or table alias in the middle of a SQL statement?

  • RE: Kill All Spid(s) according to Database Name

    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...

  • RE: Kill All Spid(s) according to Database Name

    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...

  • RE: How can I return value from function that comes from dynamic sql

    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...

  • RE: Kill All Spid(s) according to Database Name

    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...

  • RE: Find lottery winner

    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...

  • RE: Issue Connecting Classic ASP pages to SQL Express 2012

    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...

  • RE: BCP when a NTEXT column contains carriage return

    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...

  • RE: BCP when a NTEXT column contains carriage return

    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...

  • RE: Find lottery winner

    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()

  • RE: Separate field based on \ character

    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...

Viewing 15 posts - 5,386 through 5,400 (of 13,465 total)