This is how to generate a new GUID in SQL Server T-SQL:
SELECT newid()
Result:
1CA040D5-53D6-4E7C-8D36-1000C8B03A91
Technobabble from a .Net developer on the loose…
This is how to generate a new GUID in SQL Server T-SQL:
SELECT newid()
Result:
1CA040D5-53D6-4E7C-8D36-1000C8B03A91
I’m back now from my parental leave, so here’s the first posting in a while…
Ever installed SQL Server forgetting to install the client tools such as Management Studio, Profiler, etc? Here’s how to install them the easiest way.
Instead of running the main installation program, which may or may not work, run [drive]:\SQL Server x86\Tools\Setup\SqlRun_Tools.msi to install the tools directly. Much quicker and we’re not depending on updates made to SQL Server since the installation.
Tip found here.
/Emil
It can sometimes be useful to know the id of a given database, e.g. for filtering events when profiling. Here are a few ways to do that:
-- Current database select db_id() -- Named database select db_id('Northwind') -- All databases use master select name, dbid from sysdatabases
Here’s an easy way of extracting ISO dates from a datetime column:
select top 10 convert(varchar(10),starttid, 120) as datum -- style = 120 results in yyyy-mm-dd from pass
Result:
2005-08-02 2005-08-04
When doing an UPDATE and there are two occurrances of the table to update, then use the alias as table name. Example
update alias1 -- NOT the table name! set foo = 'bar' from table_foobar alias1 inner join table_foobar alias2 on alias2.foo = alias1.bar