grab our rss feed

stevienova.com

Homepage of Steve Novoselac

Entries Tagged ‘SQL’

SQL Server Reporting Services: Quick way to get 10 digit year (all the zero’s) using String.Format

Dates are fun. See, by default most dates come out like 5/6/2008. But computers, and programs like them formatted as 05/06/2008. That way, all the dates, no matter what month or day, are all the same length, cool huh?
Well, in Reporting Services, if you have a date field coming back in a dataset, and you [...]

Leave a Comment | 54 views

SQL DBA: Function To Get Database Last Restore Time (From Log Shipping Filename)

If you need to get the last time that a database is restored from log shipping based off the transaction log file name, here is a function to do so. It parses out the date from the "last_restored_file" column, then converts it from UTC to your regular time.
 
CREATE FUNCTION [dbo].[GetLogShippingFileDate] ( [...]

Leave a Comment | 115 views

SQL Server: sp_add_job - parameter passing

I am sure there are other SQL procedures that take parameters the same way, but I recently have been dealing with sp_add_job. You can call the procedure and pass in parameters
sp_add_job @job_name = ‘My Job Name’
for an example. But..you cannot do this
DECLARE @test AS [...]

Comments (1) | 303 views

How To: Connect to SQL Server, VS TFS, etc using Windows Authentication when computer is not on Active Directory Domain (XP and Vista!)

Whew, long title, amazing results!
Problem: You have a laptop or computer and you are working remotely for a company. You VPN in. Your computer is not on their Active Directory (AD) domain. You try to connect to SQL Server using SSMS or Analysis Services using Excel, but it doesn’t work because it is using your [...]

Leave a Comment | 773 views

SQL: Moving log files for an existing database to another drive

So today, Chris asked me how to move log files or data files on SQL to another drive. My first response was to use the GUI and just detach and then move the files, reattach using the GUI. But he wanted to move just the log files, I don’t think it is very intuitive with [...]

Leave a Comment | 701 views

SQL Server: SELECT Current Database Name

As a short follow up to a post I did a little while ago on SELECT’ing the instance and machine names from SQL Server, here is how you get the Current Database Name
SELECT db_name()
Funny because I was looking for that online, and my Google search led me to my past blog post, so I figured [...]

Leave a Comment | 178 views

SQL Server: SELECT Machine, Computer, Instance Names

to get the instance name: SELECT @@ServerName
to get the machine name of the server: SELECT SERVERPROPERTY(”MachineName”)
to get the machine name of the computer running the query: SELECT host_name()
one tip: cast the serverproperty as a varchar if you want to use it in a string or you will get errors in your stored procs/queries.
Technorati tags: SQL [...]

Comments (1) | 413 views

Crisis Mode Burnout and SQL Server Tips

Ever have one of those weeks where everything is a crisis or you are in “alert” mode all week? It is pretty draining. The worst part about it is, nothing else gets done, things fall behind, etc. Lesson learned: if you have a sql database and you are seeing tons of connections and cannot find [...]

Comments (1) | 112 views

SQL: How To Do Date Reoccurrence

If you use Microsoft Outlook, you know that when you set up a meeting or appointment, you can select an option like “The 4th Monday of every month”. Well, today I had to correlate this to a SQL statement and it through me for a loop: Well, yeah, I used a loop. Check it [...]

Leave a Comment | 72 views

Microsoft SQL Server 2005 Summit

Microsoft SQL Server 2005 Summit - Twin Cities…
Went to this all day Thursday in the cites. Went to the developer track. Learned about programming with SQL 2005, then about the new
SQL Server Integration Services and how to do data mining and things like that. Then learned about Advanced SQL Server Reporting Services and the changes [...]

Leave a Comment | 81 views