SELECT distinct b.name
FROM master.dbo.sysprocesses a, master.dbo.sysdatabases b
WHERE b.dbid = a.dbid
AND a.uid = USER_ID(USER)
Search This Blog
Tuesday, March 30, 2010
Friday, March 19, 2010
How to detect platform using javascript?
var platform = navigator.platform;
alert('You are using'+ platform);
alert('You are using'+ platform);
How to detect browser using javascript
You can detect your running browser as follows:
var browser = navigator.userAgent;
if(browser.indexOf('MSIE') !=-1)
alert('You are using Internet Explorer');
else if(browser.indexOf('firefox') !=-1)
{
alert('You are using Firefox');
}
else if(browser.indexOf('opera') !=-1)
{
alert('You are using Opera');
}
var browser = navigator.userAgent;
if(browser.indexOf('MSIE') !=-1)
alert('You are using Internet Explorer');
else if(browser.indexOf('firefox') !=-1)
{
alert('You are using Firefox');
}
else if(browser.indexOf('opera') !=-1)
{
alert('You are using Opera');
}
Thursday, March 11, 2010
If it is intended as a parameter to a table-valued function, ensure that your database compatibility mode is set to 90.
if your database compatibility mode is not set to 90 then the below query
declare @d table (a varchar(10), b varchar(20))
insert into @d
values(11111,'1,23,4')
insert into @d
values(11112,'11,231,41')
select a, c.val
from @d cross Apply
fnStringtoTable( b ) c
will throw an error:
"b" is not a recognized table hints option. If it is intended as a parameter to a table-valued function, ensure that your database compatibility mode is set to 90.
If above error comes then do as follows:
EXEC sp_dbcmptlevel 'EZTEST' , 90
GO
declare @d table (a varchar(10), b varchar(20))
insert into @d
values(11111,'1,23,4')
insert into @d
values(11112,'11,231,41')
select a, c.val
from @d cross Apply
fnStringtoTable( b ) c
For More details visit here http://blogs.msdn.com/psssql/archive/2007/10/16/database-compatibility-and-new-features.aspx
Output:
declare @d table (a varchar(10), b varchar(20))
insert into @d
values(11111,'1,23,4')
insert into @d
values(11112,'11,231,41')
select a, c.val
from @d cross Apply
fnStringtoTable( b ) c
will throw an error:
"b" is not a recognized table hints option. If it is intended as a parameter to a table-valued function, ensure that your database compatibility mode is set to 90.
If above error comes then do as follows:
EXEC sp_dbcmptlevel 'EZTEST' , 90
GO
declare @d table (a varchar(10), b varchar(20))
insert into @d
values(11111,'1,23,4')
insert into @d
values(11112,'11,231,41')
select a, c.val
from @d cross Apply
fnStringtoTable( b ) c
For More details visit here http://blogs.msdn.com/psssql/archive/2007/10/16/database-compatibility-and-new-features.aspx
Output:
| a | b |
| 11111 | 1 |
| 11111 | 23 |
| 11111 | 4 |
| 11112 | 11 |
| 11112 | 231 |
| 11112 | 41 |
Thursday, March 4, 2010
How to read / download the content of a web page using C# and store it in a file?
Using below code you can read and download the content of of web page.
In this example strUrl is the of a web page and strFilePath is Physical location to save the contents.
using System;
using System.IO;
using System.Net;
using System.Text;
...
public static void GetFile(string strURL,string strFilePath)
{
WebRequest myWebRequest = WebRequest.Create(strURL);
WebResponse myWebResponse = myWebRequest.GetResponse(); Stream ReceiveStream = myWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader( ReceiveStream, encode ); string strResponse=readStream.ReadToEnd();
StreamWriter oSw=new StreamWriter(strFilePath);
oSw.WriteLine(strResponse);
oSw.Close();
readStream.Close();
myWebResponse.Close();
}
In this example strUrl is the of a web page and strFilePath is Physical location to save the contents.
using System;
using System.IO;
using System.Net;
using System.Text;
...
public static void GetFile(string strURL,string strFilePath)
{
WebRequest myWebRequest = WebRequest.Create(strURL);
WebResponse myWebResponse = myWebRequest.GetResponse(); Stream ReceiveStream = myWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader( ReceiveStream, encode ); string strResponse=readStream.ReadToEnd();
StreamWriter oSw=new StreamWriter(strFilePath);
oSw.WriteLine(strResponse);
oSw.Close();
readStream.Close();
myWebResponse.Close();
}
Tuesday, February 23, 2010
How to alter a column name of a table using sql query
To update the column name of an sql table find the id of table from sysobjects table and update the syscolumns table as follows.
DECLARE @id INT
SELECT @id=[id] FROM sysobjects WHERE [name] = 'ContactDetails'
UPDATE syscolumns SET [name] ='Users_ID' WHERE [id]=@id AND [name] = 'UserID'
DECLARE @id INT
SELECT @id=[id] FROM sysobjects WHERE [name] = 'ContactDetails'
UPDATE syscolumns SET [name] ='Users_ID' WHERE [id]=@id AND [name] = 'UserID'
Wednesday, February 10, 2010
How to find the object dependencies using SQL Query
Below is the sql query to find dependencies of a table(ListingHdr).
SELECT TableName, DependentObject
FROM (
SELECT DISTINCT
o.Name 'TableName',
op.Name 'DependentObject'
FROM SysObjects o
INNER Join SysDepends d ON d.DepId = o.Id
INNER Join SysObjects op on op.Id = d.Id
WHERE o.XType = 'U' and o.name = 'ListingHdr'
GROUP BY o.Name, o.Id, op.Name
) x
SELECT TableName, DependentObject
FROM (
SELECT DISTINCT
o.Name 'TableName',
op.Name 'DependentObject'
FROM SysObjects o
INNER Join SysDepends d ON d.DepId = o.Id
INNER Join SysObjects op on op.Id = d.Id
WHERE o.XType = 'U' and o.name = 'ListingHdr'
GROUP BY o.Name, o.Id, op.Name
) x
Subscribe to:
Posts (Atom)