SQL Scripties
mareen:

Oh dude, digital storage. I am somewhere around »external #18« by now.
But I am SO happy to be using MacOS and being able to swap stuff around quickly.

Someone needs a drobo

mareen:

Oh dude, digital storage. I am somewhere around »external #18« by now.

But I am SO happy to be using MacOS and being able to swap stuff around quickly.

Someone needs a drobo

Extremely high volume of whales

twitterstatus:

We are experiencing an outage due to an extremely high number of whales.  Our on-call team is working on a fix.

its not like twitter actually does anything else; where is the scaling issue coming from at this point?

Gaps

One feature I wish SQL Management Studio had is Paste and increment number. I frequently have to populate tables of lists with a integer reference code. If i have a code string of:

Insert into MyTable Select 1, ‘EN’, …

It would be great if i could paste in the value and have it change the 1 to a 2.

Changing SQL Server collation without DTS

If you find yourself needing to change collation on databases when you restore them; you can DTS the data but that is fraught with risk. the fantastic script here

http://www.db-staff.com/index.php/microsoft-sql-server/69-change-collation

can do it in one pass without changing the objects in the  database :)

Lonely Planet iPhone Content List 12/1/10

Taken from the Buy Guides feature of the Lonely Planet iPhone application; as there doesn’t seem to be a list anywhere else. The application came with Mexican Phrasebook and San Francisco City Guide pre installed.

  • Amsterdam City Guide
  • Arabic Phrasebook
  • Auckland City Guide
  • Bangkok City Guide
  • Barcelona City Guide
  • Beijing City Guide
  • Belfast City Guide
  • Berlin City Guide
  • Boston City Guide
  • Budapest City Guide
  • Buenos Aires City Guide
  • Cantonese Phrasebook
  • Cape Town City Guide
  • Chiang Mai City Guide
  • Chicago City Guide
  • Copenhagen City Guide
  • Czech Phrase Book
  • Delhi City Guide
  • Dubai City Guide
  • Dublin City Guide
  • Edinburgh City Guide
  • French Phrasebook
  • German Phrasebook
  • Glasgow City Guide
  • Greek Phrasebook
  • Havana City Guide
  • Hong Kong City Guide
  • Istanbul City Guide
  • Italian Phrasebook
  • Japanese Phrasebook
  • Korean Phrasebook
  • Kuala Lumpur Phrasebook
  • Kyoto City Guide
  • Las Vegas City Guide
  • Lisbon City Guide
  • London City Guide
  • Lyon City Guide
  • Macau City Guide
  • Madrid City Guide
  • Manchester City Guide
  • Mandarin Phrasebook
  • Marrakesh City Guide
  • Melbourne City Guide
  • Mexico City Guide
  • Miami City Guide
  • Moscow City Guide
  • Munich City Guide
  • New Orleans City Guide
  • New York City City Guide
  • Oslo City Guide
  • Paris City Guide
  • Polish Phrasebook
  • Portuguese Phrasebook
  • Prague City Guide
  • Rio De Janeiro City Guide
  • Rom City Guide
  • Seattle City  Guide
  • Seoul City Guide
  • Shanghai City Guide
  • Singapore City Guide
  • Spanish Phrasebook
  • St Petersburg City Guide
  • Stockholm City Guide
  • Stuttgart City Guide
  • Swahili Phrasebook
  • Sydney City Guide
  • Thai Phrasebook
  • Tokyo City Guide
  • Toronto City Guide
  • Turkish Phrasebook
  • Vancouver City Guide
  • Venice City Guide
  • Vienna City Guide
  • Vietnamese Phrasebook
  • Washington DC City Guide
Regex - Simple Example for wildcard users

I can’t sit down and write regex; as i use it so infrequently. SQL Management studio’s support for wildcards provides support for most things I need. Sourcesafe doesn’t have that same search facility and required me to use regex. Figured that text*text was a standard thing to use it for; only couldn’t find any examples on the web. What i came up with was Text.*Text

Windows XP / Remote Desktop Connection Woes

“Unable to log you in because of an account restriction” This means you need to set a password on the Account and by default Windows XP requires one for remote desktop connections. Set a password and all should be well.

Enable xp_cmdshell in SQl 2008

If you need to call xp_cmdshell you need to allow it; this script enables it.

EXEC sp_configure ‘show advanced options’, 1

GO

RECONFIGURE

GO

EXEC sp_configure ‘xp_cmdshell’, 1

GO

RECONFIGURE

GO

Terminal Services Licensing Work Around

Found myself dialing onto a terminal server for admin that i rarely use this morning; only to get the dreaded your license to use this has expired message. If you want to clear that you need to delete a registry key.

The Key is

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSLicensing\

Delete that whole key including all subfolders. When you go back into terminal services client it is recreated. If you find that when you run the terminal services client again, the registry key isn’t re-created. To have it re-created, run mstsc.exe as Administrator.

SQL 2008 Upload Files from Folder into Table

In the dark days there was a simple exe for uploading files into a database; that has gone. Found myself working on a data import and need to upload my files into blob;s openquery is my friend. You need to enable cmd shell or find another way of getting the file names into SQL Server but this will let you pick up all the files in a folder in one hit. Its quick too 10k RTF / Word Files on my test server took about 2 minutes.

go

drop table dbo.FilesInFolder

drop table myTable2

Create Table dbo.FilesInFolder(myFileName nvarchar(255))

Create TABLE myTable2(Document image, myFileName nvarchar(255))

Insert into FilesInFolder

exec master..xp_cmdshell ‘for %a in (C:\Users\Administrator\Desktop\F01\*.*) do @echo %a’

exec master..xp_cmdshell ‘for %a in (C:\Users\Administrator\Desktop\Excel\*.*) do @echo %a’

Alter table FilesInFolder add FileNumber int identity(1,1)

Declare @i int, @maxi int, @FileName nvarchar(1000), @mYSQL nvarchar(4000)

Select @i = 1, @maxi = COUNT(*) from FilesInFolder where not myFileName is null

While @i <= @maxi

Begin

select @FileName = myfilename from FilesInFolder where filenumber = @i

select @mYSQL = ‘INSERT INTO myTable2(Document, myfilename) SELECT *, ”’ + REPLACE(@FileName,’C:\Users\Administrator\Desktop\F01',”) + ”’ FROM OPENROWSET(BULK N”’ + @FileName + ”’, SINGLE_BLOB) as i’

exec sp_executesql @mYSQL

select @i = @i + 1

End