Tags: , , , | Categories: Script, Tip, Veritabanı Posted by okutbay on 22.04.2011 19:53 | Yorumlar (0)

SQL Serverda text deger içeren bir kolonda like ile sorgulama yapmak istediğinizde arama kriteriniz sorgularda özel anlamı olan karakterler içeriyorsa [] içinde kullanabilirsiniz

Örneğin "_" içere arama kriterlerinde [] içinde yazarsanız sorgunu o kolonda içinde "_" geçen kayıtları döndürecektir... 

Bu yazıyı ilk değerlendiren siz olun

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , , | Categories: Veritabanı Posted by okutbay on 19.11.2009 09:33 | Yorumlar (0)

It's always hard to make modifications to code or database design especially if you don't know anything about the business process.

In sql server 2005 (or 2008) you can use sp_depends stored procedure to obtain dependency between the objects such as table, view or stored procedure.

For example just run 'sp_depends Users' script to determine which views or storep porcedures are using this table.

If you use this stored procedure with views or stored procedures it can show you the objects used in it and  objects uses it.

 

More Information: sp_depends (Transact-SQL)

 

Happy codding...

Bu yazıyı ilk değerlendiren siz olun

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , | Categories: Veritabanı Posted by okutbay on 28.10.2009 16:44 | Yorumlar (0)

You can use T-Sql's COALESCE function to combine your data into a single string. Here is a simple sample: 

DECLARE @str VARCHAR(100)

SELECT @str = COALESCE(@str + '|', '') + Firstname

FROM Members with(nolock)

Print @str

 

Result

Ilbay|Talha|Roberte|Theıoden|Cihan|Sagolee|Kazım|Mehmet|Recep|Alp|Haci|Ömer

 

Happy coding...

Bu yazıyı ilk değerlendiren siz olun

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , | Categories: Security, Veritabanı Posted by okutbay on 25.09.2009 10:39 | Yorumlar (0)

I was gettin this error  when i try to execute a stored procedure from linked server.

Executed as user: XXX\yyy. The OLE DB provider "SQLNCLI"
for linked server "LSQL02" reported an error.
Authentication failed. [SQLSTATE 42000] (Error 7399)  Cannot initialize the data source object of OLE DB provider "SQLNCLI" for linked server "LSQL02". [SQLSTATE 42000] (Error 7303)  OLE DB provider "SQLNCLI" for linked server "LSQL02" returned message "Invalid authorization specification". [SQLSTATE 01000] (Error 7412).  The step failed.

To solve you can map Servers local user to remote servers user with executing 'sp_addlinkedsrvlogin'

EXEC sp_addlinkedsrvlogin @rmtsrvname = 'linkedservername'

      , @useself = 'FALSE'

      , @locallogin = 'localuser'

      , @rmtuser = 'remoteuser'

      , @rmtpassword = 'remoteuserpassword'

To remove user mapping.

 

EXEC sp_droplinkedsrvlogin @rmtsrvname = 'linkedservername'

      ,@locallogin = 'localuser'

 

References

Security for Linked Servers
http://msdn.microsoft.com/en-us/library/ms175537.aspx

sp_addlinkedsrvlogin (Transact-SQL)
http://msdn.microsoft.com/en-us/library/ms189811.aspx

sp_droplinkedsrvlogin (Transact-SQL)
http://msdn.microsoft.com/en-us/library/ms186218.aspx

 

 

Bu yazıyı ilk değerlendiren siz olun

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5