EppesConsulting Blog

The Random Tech Stuff I Run Into Every Day

Browsing Posts in database

I’ve found this page very
handy when it comes to writing LINQ queries.

From this site:

select @@VERSION

exec sp_server_info

SELECT SERVERPROPERTY(‘ProductLevel’)

  No SP
(RTM or Golden)
SP1 SP2 SP3 / SP3a SP4 SP5 SP5a
SQL Server 6.0 6.00.121 6.00.124 6.00.139 6.00.151       
SQL Server 6.5
(Hydra)
6.50.201 6.50.213 6.50.240 6.50.258 6.50.281 6.50.415 6.50.416 
SQL Server 7.0
(Sphinx)
7.00.623 7.00.699 7.00.842  7.00.961 7.00.1063    
SQL Server 2000
(Shiloh)
8.00.194 8.00.384 8.00.534 8.00.760 8.00.2039    
SQL Server 2005
(Yukon)
9.00.1399.06            

Solution 1:

Select Table_name as “Table Without PK”
From Information_schema.Tables
Where Table_type = ‘BASE TABLE’ and
Objectproperty (Object_id(Table_name), ‘TableHasPrimaryKey’) = 0 and

Objectproperty (Object_id(Table_name), ‘IsUserTable’) = 1

Solution 2:

Select [name] as “Table Without PK”

from SysObjects where xtype=’U’ and
id not in
(
Select parent_obj from SysObjects where xtype=’PK’
)

It threw me for a loop when a Cisco CallManager version of a SQL server was on an
abnormal port (not 1433).  It took me a while to find it, but if you want to
connect to a non-standard TCP/IP port from SQL Management Studio, simply connect to
the hostname then a comma with the port number.

Example:  MySqlServer.MyDomain.com,3821

I stole this information from here.

I don’t really set up database servers that often, but every time I do, I struggle
to remember how to set up email functionality.  In SQL 2000 it was “SQL Mail”. 
In SQL 2005, it’s “Database Mail”.

Here’s a good howto on how to set
up SQL 2005 Database Mail
.

How do you transfer logins from one SQL server to another:

http://support.microsoft.com/kb/246133/

 

How do you fix orphaned SQL server users:

http://www.fileformat.info/tip/microsoft/sql_orphan_user.htm

Ever been annoyed that your LINQ connection string isn’t stored in the web.config
file?  Here’s how to fix that:

http://blog.newguid.net/post/Linq-to-Sql-Change-connectionstring-to-load-from-Webconfig.aspx

To me, this is almost a necessity to make applications deployable between environments.

If you’re like me, you’re always getting the first few rows of data from a table as
you browse around a database in Query Analyzer.  Of course now, the SQL Management
Studio does this for you, but just in case you’re using MySQL or Oracle, here are
the equivalent commands:

http://dotnet.org.za/thea/archive/2005/02/22/14715.aspx

Ever wondered how to bulk script data for a database?  This would be really handy
for default table data during an install, or to copy a database you only have user
level access to.  Enter sp_generate_inserts:

http://vyaskn.tripod.com/code.htm

I found the answer here:  http://johnnynine.com/blog/HowToListThisIndexesOnAnOracleTable.aspx

Script:

select index_name,
column_name, column_position from user_ind_columns
where table_name=‘MYTABLENAME’ order by index_name,
column_position