I created a linked server and use it to select data from one server to another.
Is there another way except for linked server which will do the same job?
OPENROWSET lets you define the connection properties, but you need to have access/permissi0ons, whether via trusted connection or with a username and password;
you also have to create a static string, openrowset does not access parameters, only static strings...
so if in this contrived example i needed records for ORGID = 811 and also 812, i'd have to do everything with dynamic SQL or modify this static string of the parameters.
--database name required
FROM OPENROWSET( 'SQLNCLI',
'SET FMTONLY OFF; SET NOCOUNT ON; SELECT ColumnList FROM Db_Name.dbo.GetCategoriesByDocIDAsTable WHERE ORGID = 811'
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!