SQLTeam.com | Weblogs | Forums

Talking to SQL Server via network port

sql2012

#1

Hello! I use SQL Server 2012, but I need to make simple embedded devices that can inject data into SQL Server tables. I assume (?) there is a port where I can connect to SQL Server and, with proper credentials, speak SQL to it? Does anyone know any details about this, or where I can find out more?


#2

Normally TCP port 1433

See: https://msdn.microsoft.com/en-us/ms177440.aspx


#3

Thanks! That tells me how to get the port open. But is there a protocol document anywhere about how to communicate with the server through it? Is it simply SQL statements? How about authentication? Maybe I am expecting it to be more complex than it actually is?


#4

Sorry, I don't know the details at that level. I use a transport layer between me and the database such that I don't have to worry about it! Clearly the folk that wrote the drivers for that have done so though.

Is it an option for you to use pre-existing database connectivity drivers of some sort?

But other than that, yes, basically SQL is sent across the wire to the port and then a resultset comes back the other way. I'm sure there must be some handshakes and ACKs involved too ... but that's, mercifully, something I've never had to worry about!

Hopefully someone who understands those layers of the network transport will be along shortly :slight_smile:


#5

As @Kristen mentioned, use an existing database driver which will handle the communication between your software and the SQL Server. For instance, there's the SQL Server Native Client driver. Which driver you use is dependent on the programming language you are using, the SQL Server version, and the features that you need.