Okay had this problem come up at work recently and it’s fantastic solution. It’s a bit hard to explain when you would need it, I guess it works well for when you’re doing table joins and need quick reference data out within a query.
Anyway here’s how you do it.
Firstly I’ve got a table ‘Test’ that contains two columns ID & Name. I’ve added some data in… Continue reading
So recently I updated some sql code for my blog, anyway I thought I’d share so here it is.
Basically go and look for every blog post where it had the old url in the content and replace it with the new url. Best to try it out on one link before you go and… Continue reading
Debugging an issue today at work, and needed to find if there was any uncommitted transactions or active transactions.
There’s a couple of ways to do this:
Thanks Pinal Dave – more from his blog post here.
Also you can use dbcc opentran Or SELECT @@TRANSCOUNT
So, if you’re like me and what to see this in action… Continue reading
Fast way to get a sql server name, great if you’re dealing with multiple sql servers.
This will return the Windows computer name on which the sql server instance is currently running on.
It will return NULL if there is an error.
This will return the instance & computer name
[code… Continue reading
Okay so recently I’ve had to select only certain columns from a large stored proc that may return like 4 columns. How to do this?
DECLARE @tableVar table (Surname varchar (100), FirstName varchar(255), Email varchar(100), Age int)
INSERT INTO @tableVar EXEC dbo.usp_getSomeData
SELECT Surname, Email FROM @tableVar… Continue reading
I’ve used this piece of code in many places lately to check if a field is nullable or blank – used mainly as a default value.
@ResultType = ” OR
@ResultType ” AND ResultType IN(@ResultType)
)… Continue reading
simple script incase you forget:
grant exec on to… Continue reading
Ever needed to delete a table? Oh wait it’s joined to another. Well here’s some how you do it… the right way!
FROM Users u
Profiles p on u.UserID = p.UserID
WHERE u.UserIsArchived = 1
DELETE u, p
FROM Users u
INNER JOIN Profiles p ON u.UserID = p.UserID
WHERE u.UserIsArchived = 1… Continue reading
Just figured I’d add one of these scripts incase I forget! Haha… but just if you’re curious, it not different to MySQL.
DROP TABLE IF EXISTS Players;
CREATE TABLE Players
PlayerID int identity,
INSERT INTO Players
Been using Fusegrid SDK, it’s fantastic for people who just want to start coding Coldfusion with zero time wasted on setup.
Normally you’ll need to setup a web server, then download ColdFusion and then work out what database you want… painful!
Fusegrid comes bundled with Railo + H2 Database, and CFWheels
Get it here: http://www.fusegrid.com/sdk/… Continue reading