ex 1.
EXEC OPENDATASOURCE('SQLOLEDB','Data Source=sername;User ID=jerry;Password=password').master.dbo.xp_cmdShell 'C:\myprogram.exe "parameter1" "parameter2"'
if 64 bits, should use:
select * from
openquery(server, 'Select * from mydb.dbo.mytable')
ex 2.
If we want to convert an table to xml, using sql, there are simple method to do this things:
select * from customer for xml auto, elements, root('customer')
ex 3.
EXEC sp_addlinkedserver 'MyServer', N'SQL Server'
ex 4.
select column_name, * from information_schema.columns where table_name='Mytable'
select table_name from information_schema.tables
(include views)
ex 5.
SELECT [name] from [sys].[tables]
(not include views)
exe 6.
EXEC sp_MSForEachTable 'TRUNCATE TABLE ?'
( EXEC sp_MSForEachTable 'DROP TABLE ?' this one need caution)
exe 7.
update table SET col = REPLACE(col, CHAR(9), ' ')
update table SET col = REPLACE(col, CHAR(13) + CHAR(10), ' ')
update table SET col = REPLACE(col, CHAR(10), ' ')
No comments:
Post a Comment