user generated tables
Select * from sysobjects where xtype='u'
system generated tables
Select * from sysobjects where xtype='s'
23 nov 2010
17 jun 2010
Generate Sql queries on the fly
BEGIN
DECLARE @TableName as nvarchar(50),@test as nvarchar(max)
SET @TableName = 'orders'
Print @TableName
SET @test = 'SELECT * FROM ' + @TableName
EXEC(@test)
END
DECLARE @TableName as nvarchar(50),@test as nvarchar(max)
SET @TableName = 'orders'
Print @TableName
SET @test = 'SELECT * FROM ' + @TableName
EXEC(@test)
END
8 jun 2010
SQL send an email from database mail
use Test
execute msdb.dbo.sp_send_dbmail
@profile_name='TEST',
@recipients = 'anemailadres@domainname.com',
@body = 'body of the mail',
@query = 'select * from orders',
@execute_query_database='',
@subject = 'subject of the mail',
@attach_query_result_as_file = 1
execute msdb.dbo.sp_send_dbmail
@profile_name='TEST',
@recipients = 'anemailadres@domainname.com',
@body = 'body of the mail',
@query = 'select * from orders',
@execute_query_database='
@subject = 'subject of the mail',
@attach_query_result_as_file = 1
7 jun 2010
SQL With TIES Example
SELECT *
FROM QryCustomersWithMostOrders
Customer OrderCount
A 3
B 3
C 1
SELECT TOP 1 *
FROM QryCustomersWithMostOrders
ORDER BY OrderCount DESC
FROM QryCustomersWithMostOrders
Customer OrderCount
A 3
B 3
C 1
SELECT TOP 1 *
FROM QryCustomersWithMostOrders
ORDER BY OrderCount DESC
Customer OrderCount
A 3
SELECT TOP 1 WITH TIES *
FROM QryCustomersWithMostOrders
ORDER BY OrderCount DESC
FROM QryCustomersWithMostOrders
ORDER BY OrderCount DESC
Customer OrderCount
A 3
B 3
9 mrt 2010
16 feb 2010
find used colums or functions in sql database
you have wrote your own function in several views or stored procedures, but you don't know anymore where you have used it? it can be difficult to find them.
i did it my way :
i did it my way :
- open Microsoft Sql Server Management studio
- select the target database
- right click => tasks=> Generate scripts
- Select the database and press next
- select where you want to search in for example views and tabels and pess next
- presss select all to select all tables and press next
- press selet all to select all viewss and pres next
- choose for example "script to new query window"
- press next and finish.
9 feb 2010
Problems & experiences with files
Files can be created by different applications. more and more they all try to follow the standards that are defined by the different institutions. On the other hand there is a wild growing forest of apps where they try to use these standards. Take pdf-files as an example. There are the original adobe apps but you find a lot of pdf programs on sourceforge. When you generate pdf files with the different tools you'll find, you'll see that you get different files. This causes problems.... strange problems....
A Time ago i had a corrupt Word file. i'm sure that the file was created with MS Office 2000. But my 2007 did nothing else then put some messageboxes on the screen. after a while i opened the file with My OpenOffice 3.0 and voilĂ ... problem solved.
In another situation I had an MS Excel 2003 file opened with my Excel 2007.
Ms Excel 2007 was in compatibility-mode. after i changed the file extension to xlsx file i discovered that the filesize reduced with more than 40%.
here are some other standard Tricks wich you can use in these kind of situations :
A Time ago i had a corrupt Word file. i'm sure that the file was created with MS Office 2000. But my 2007 did nothing else then put some messageboxes on the screen. after a while i opened the file with My OpenOffice 3.0 and voilĂ ... problem solved.
In another situation I had an MS Excel 2003 file opened with my Excel 2007.
Ms Excel 2007 was in compatibility-mode. after i changed the file extension to xlsx file i discovered that the filesize reduced with more than 40%.
here are some other standard Tricks wich you can use in these kind of situations :
- Open and Save
- open file exported from other program
- Save file in current program
- open the file and copy it to a new File
- open file
- Select all
- copy
- open new file
- paste all
- save new file
- Open it in another application / Generate the file with an other application if possible
- Install Different File viewers.
- Some programs have cleaning options.
- autocad : purge commands
- office : repair options
- find the autoRecover files from the application
- asd files for MS Word
- xar files for Ms Excel
Abonneren op:
Posts (Atom)