To get a connection string with SQL Server (t)

Source: Internet
Author: User

In general, C # Connections to SQL Server strings can be directly written directly in the documentation, or you can refer to the famous connectionstrings manual spelling

But if you are already connected to SQL Server you can also get the current connection string in T-sql:

1 SELECT  'server='2         + CONVERT(NVARCHAR( +),ISNULL(Connectionproperty ('local_net_address'),'.'))3         +  Case  whenConnectionproperty ('Local_tcp_port') is NULL  Then "' ELSE ',' END4         + CONVERT(NVARCHAR( +),ISNULL(Connectionproperty ('Local_tcp_port'),"'))+ ';d atabase=' + db_name()5         +  CaseType_desc6              when 'Windows_login'  Then '; Trusted_connection=true'7             ELSE '; uid=' + Suser_name()+ ';p Wd=yourpassword'8           END9  fromsys.server_principalsTen WHEREName= Suser_name()

To get a connection string with SQL Server (t)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.